documentation.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837
  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. _areAttributesDirty: boolean;
  7614. /** @hidden */
  7615. _areTexturesDirty: boolean;
  7616. /** @hidden */
  7617. _areFresnelDirty: boolean;
  7618. /** @hidden */
  7619. _areMiscDirty: boolean;
  7620. /** @hidden */
  7621. _areImageProcessingDirty: boolean;
  7622. /** @hidden */
  7623. _normals: boolean;
  7624. /** @hidden */
  7625. _uvs: boolean;
  7626. /** @hidden */
  7627. _needNormals: boolean;
  7628. /** @hidden */
  7629. _needUVs: boolean;
  7630. [id: string]: any;
  7631. /**
  7632. * Specifies if the material needs to be re-calculated
  7633. */
  7634. readonly isDirty: boolean;
  7635. /**
  7636. * Marks the material to indicate that it has been re-calculated
  7637. */
  7638. markAsProcessed(): void;
  7639. /**
  7640. * Marks the material to indicate that it needs to be re-calculated
  7641. */
  7642. markAsUnprocessed(): void;
  7643. /**
  7644. * Marks the material to indicate all of its defines need to be re-calculated
  7645. */
  7646. markAllAsDirty(): void;
  7647. /**
  7648. * Marks the material to indicate that image processing needs to be re-calculated
  7649. */
  7650. markAsImageProcessingDirty(): void;
  7651. /**
  7652. * Marks the material to indicate the lights need to be re-calculated
  7653. */
  7654. markAsLightDirty(): void;
  7655. /**
  7656. * Marks the attribute state as changed
  7657. */
  7658. markAsAttributesDirty(): void;
  7659. /**
  7660. * Marks the texture state as changed
  7661. */
  7662. markAsTexturesDirty(): void;
  7663. /**
  7664. * Marks the fresnel state as changed
  7665. */
  7666. markAsFresnelDirty(): void;
  7667. /**
  7668. * Marks the misc state as changed
  7669. */
  7670. markAsMiscDirty(): void;
  7671. /**
  7672. * Rebuilds the material defines
  7673. */
  7674. rebuild(): void;
  7675. /**
  7676. * Specifies if two material defines are equal
  7677. * @param other - A material define instance to compare to
  7678. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7679. */
  7680. isEqual(other: MaterialDefines): boolean;
  7681. /**
  7682. * Clones this instance's defines to another instance
  7683. * @param other - material defines to clone values to
  7684. */
  7685. cloneTo(other: MaterialDefines): void;
  7686. /**
  7687. * Resets the material define values
  7688. */
  7689. reset(): void;
  7690. /**
  7691. * Converts the material define values to a string
  7692. * @returns - String of material define information
  7693. */
  7694. toString(): string;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7701. * 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;
  7702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7703. */
  7704. export class ColorCurves {
  7705. private _dirty;
  7706. private _tempColor;
  7707. private _globalCurve;
  7708. private _highlightsCurve;
  7709. private _midtonesCurve;
  7710. private _shadowsCurve;
  7711. private _positiveCurve;
  7712. private _negativeCurve;
  7713. private _globalHue;
  7714. private _globalDensity;
  7715. private _globalSaturation;
  7716. private _globalExposure;
  7717. /**
  7718. * Gets the global Hue value.
  7719. * 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).
  7720. */
  7721. /**
  7722. * Sets the global Hue value.
  7723. * 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).
  7724. */
  7725. globalHue: number;
  7726. /**
  7727. * Gets the global Density value.
  7728. * 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.
  7729. * Values less than zero provide a filter of opposite hue.
  7730. */
  7731. /**
  7732. * Sets the global Density value.
  7733. * 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.
  7734. * Values less than zero provide a filter of opposite hue.
  7735. */
  7736. globalDensity: number;
  7737. /**
  7738. * Gets the global Saturation value.
  7739. * 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.
  7740. */
  7741. /**
  7742. * Sets the global Saturation value.
  7743. * 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.
  7744. */
  7745. globalSaturation: number;
  7746. /**
  7747. * Gets the global Exposure value.
  7748. * 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.
  7749. */
  7750. /**
  7751. * Sets the global Exposure value.
  7752. * 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.
  7753. */
  7754. globalExposure: number;
  7755. private _highlightsHue;
  7756. private _highlightsDensity;
  7757. private _highlightsSaturation;
  7758. private _highlightsExposure;
  7759. /**
  7760. * Gets the highlights Hue value.
  7761. * 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).
  7762. */
  7763. /**
  7764. * Sets the highlights Hue value.
  7765. * 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).
  7766. */
  7767. highlightsHue: number;
  7768. /**
  7769. * Gets the highlights Density value.
  7770. * 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.
  7771. * Values less than zero provide a filter of opposite hue.
  7772. */
  7773. /**
  7774. * Sets the highlights Density value.
  7775. * 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.
  7776. * Values less than zero provide a filter of opposite hue.
  7777. */
  7778. highlightsDensity: number;
  7779. /**
  7780. * Gets the highlights Saturation value.
  7781. * 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.
  7782. */
  7783. /**
  7784. * Sets the highlights Saturation value.
  7785. * 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.
  7786. */
  7787. highlightsSaturation: number;
  7788. /**
  7789. * Gets the highlights Exposure value.
  7790. * 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.
  7791. */
  7792. /**
  7793. * Sets the highlights Exposure value.
  7794. * 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.
  7795. */
  7796. highlightsExposure: number;
  7797. private _midtonesHue;
  7798. private _midtonesDensity;
  7799. private _midtonesSaturation;
  7800. private _midtonesExposure;
  7801. /**
  7802. * Gets the midtones Hue value.
  7803. * 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).
  7804. */
  7805. /**
  7806. * Sets the midtones Hue value.
  7807. * 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).
  7808. */
  7809. midtonesHue: number;
  7810. /**
  7811. * Gets the midtones Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. /**
  7816. * Sets the midtones Density value.
  7817. * 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.
  7818. * Values less than zero provide a filter of opposite hue.
  7819. */
  7820. midtonesDensity: number;
  7821. /**
  7822. * Gets the midtones Saturation value.
  7823. * 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.
  7824. */
  7825. /**
  7826. * Sets the midtones Saturation value.
  7827. * 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.
  7828. */
  7829. midtonesSaturation: number;
  7830. /**
  7831. * Gets the midtones Exposure value.
  7832. * 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.
  7833. */
  7834. /**
  7835. * Sets the midtones Exposure value.
  7836. * 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.
  7837. */
  7838. midtonesExposure: number;
  7839. private _shadowsHue;
  7840. private _shadowsDensity;
  7841. private _shadowsSaturation;
  7842. private _shadowsExposure;
  7843. /**
  7844. * Gets the shadows Hue value.
  7845. * 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).
  7846. */
  7847. /**
  7848. * Sets the shadows Hue value.
  7849. * 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).
  7850. */
  7851. shadowsHue: number;
  7852. /**
  7853. * Gets the shadows Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. /**
  7858. * Sets the shadows Density value.
  7859. * 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.
  7860. * Values less than zero provide a filter of opposite hue.
  7861. */
  7862. shadowsDensity: number;
  7863. /**
  7864. * Gets the shadows Saturation value.
  7865. * 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.
  7866. */
  7867. /**
  7868. * Sets the shadows Saturation value.
  7869. * 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.
  7870. */
  7871. shadowsSaturation: number;
  7872. /**
  7873. * Gets the shadows Exposure value.
  7874. * 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.
  7875. */
  7876. /**
  7877. * Sets the shadows Exposure value.
  7878. * 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.
  7879. */
  7880. shadowsExposure: number;
  7881. /**
  7882. * Returns the class name
  7883. * @returns The class name
  7884. */
  7885. getClassName(): string;
  7886. /**
  7887. * Binds the color curves to the shader.
  7888. * @param colorCurves The color curve to bind
  7889. * @param effect The effect to bind to
  7890. * @param positiveUniform The positive uniform shader parameter
  7891. * @param neutralUniform The neutral uniform shader parameter
  7892. * @param negativeUniform The negative uniform shader parameter
  7893. */
  7894. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7895. /**
  7896. * Prepare the list of uniforms associated with the ColorCurves effects.
  7897. * @param uniformsList The list of uniforms used in the effect
  7898. */
  7899. static PrepareUniforms(uniformsList: string[]): void;
  7900. /**
  7901. * Returns color grading data based on a hue, density, saturation and exposure value.
  7902. * @param filterHue The hue of the color filter.
  7903. * @param filterDensity The density of the color filter.
  7904. * @param saturation The saturation.
  7905. * @param exposure The exposure.
  7906. * @param result The result data container.
  7907. */
  7908. private getColorGradingDataToRef;
  7909. /**
  7910. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7911. * @param value The input slider value in range [-100,100].
  7912. * @returns Adjusted value.
  7913. */
  7914. private static applyColorGradingSliderNonlinear;
  7915. /**
  7916. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7917. * @param hue The hue (H) input.
  7918. * @param saturation The saturation (S) input.
  7919. * @param brightness The brightness (B) input.
  7920. * @result An RGBA color represented as Vector4.
  7921. */
  7922. private static fromHSBToRef;
  7923. /**
  7924. * Returns a value clamped between min and max
  7925. * @param value The value to clamp
  7926. * @param min The minimum of value
  7927. * @param max The maximum of value
  7928. * @returns The clamped value.
  7929. */
  7930. private static clamp;
  7931. /**
  7932. * Clones the current color curve instance.
  7933. * @return The cloned curves
  7934. */
  7935. clone(): ColorCurves;
  7936. /**
  7937. * Serializes the current color curve instance to a json representation.
  7938. * @return a JSON representation
  7939. */
  7940. serialize(): any;
  7941. /**
  7942. * Parses the color curve from a json representation.
  7943. * @param source the JSON source to parse
  7944. * @return The parsed curves
  7945. */
  7946. static Parse(source: any): ColorCurves;
  7947. }
  7948. }
  7949. declare module BABYLON {
  7950. /**
  7951. * Interface to follow in your material defines to integrate easily the
  7952. * Image proccessing functions.
  7953. * @hidden
  7954. */
  7955. export interface IImageProcessingConfigurationDefines {
  7956. IMAGEPROCESSING: boolean;
  7957. VIGNETTE: boolean;
  7958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7959. VIGNETTEBLENDMODEOPAQUE: boolean;
  7960. TONEMAPPING: boolean;
  7961. TONEMAPPING_ACES: boolean;
  7962. CONTRAST: boolean;
  7963. EXPOSURE: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. }
  7971. /**
  7972. * @hidden
  7973. */
  7974. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7975. IMAGEPROCESSING: boolean;
  7976. VIGNETTE: boolean;
  7977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7978. VIGNETTEBLENDMODEOPAQUE: boolean;
  7979. TONEMAPPING: boolean;
  7980. TONEMAPPING_ACES: boolean;
  7981. CONTRAST: boolean;
  7982. COLORCURVES: boolean;
  7983. COLORGRADING: boolean;
  7984. COLORGRADING3D: boolean;
  7985. SAMPLER3DGREENDEPTH: boolean;
  7986. SAMPLER3DBGRMAP: boolean;
  7987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7988. EXPOSURE: boolean;
  7989. constructor();
  7990. }
  7991. /**
  7992. * This groups together the common properties used for image processing either in direct forward pass
  7993. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7994. * or not.
  7995. */
  7996. export class ImageProcessingConfiguration {
  7997. /**
  7998. * Default tone mapping applied in BabylonJS.
  7999. */
  8000. static readonly TONEMAPPING_STANDARD: number;
  8001. /**
  8002. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8003. * to other engines rendering to increase portability.
  8004. */
  8005. static readonly TONEMAPPING_ACES: number;
  8006. /**
  8007. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8008. */
  8009. colorCurves: Nullable<ColorCurves>;
  8010. private _colorCurvesEnabled;
  8011. /**
  8012. * Gets wether the color curves effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the color curves effect is enabled.
  8016. */
  8017. colorCurvesEnabled: boolean;
  8018. private _colorGradingTexture;
  8019. /**
  8020. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8021. */
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. colorGradingTexture: Nullable<BaseTexture>;
  8026. private _colorGradingEnabled;
  8027. /**
  8028. * Gets wether the color grading effect is enabled.
  8029. */
  8030. /**
  8031. * Sets wether the color grading effect is enabled.
  8032. */
  8033. colorGradingEnabled: boolean;
  8034. private _colorGradingWithGreenDepth;
  8035. /**
  8036. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. colorGradingWithGreenDepth: boolean;
  8042. private _colorGradingBGR;
  8043. /**
  8044. * Gets wether the color grading texture contains BGR values.
  8045. */
  8046. /**
  8047. * Sets wether the color grading texture contains BGR values.
  8048. */
  8049. colorGradingBGR: boolean;
  8050. /** @hidden */
  8051. _exposure: number;
  8052. /**
  8053. * Gets the Exposure used in the effect.
  8054. */
  8055. /**
  8056. * Sets the Exposure used in the effect.
  8057. */
  8058. exposure: number;
  8059. private _toneMappingEnabled;
  8060. /**
  8061. * Gets wether the tone mapping effect is enabled.
  8062. */
  8063. /**
  8064. * Sets wether the tone mapping effect is enabled.
  8065. */
  8066. toneMappingEnabled: boolean;
  8067. private _toneMappingType;
  8068. /**
  8069. * Gets the type of tone mapping effect.
  8070. */
  8071. /**
  8072. * Sets the type of tone mapping effect used in BabylonJS.
  8073. */
  8074. toneMappingType: number;
  8075. protected _contrast: number;
  8076. /**
  8077. * Gets the contrast used in the effect.
  8078. */
  8079. /**
  8080. * Sets the contrast used in the effect.
  8081. */
  8082. contrast: number;
  8083. /**
  8084. * Vignette stretch size.
  8085. */
  8086. vignetteStretch: number;
  8087. /**
  8088. * Vignette centre X Offset.
  8089. */
  8090. vignetteCentreX: number;
  8091. /**
  8092. * Vignette centre Y Offset.
  8093. */
  8094. vignetteCentreY: number;
  8095. /**
  8096. * Vignette weight or intensity of the vignette effect.
  8097. */
  8098. vignetteWeight: number;
  8099. /**
  8100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8101. * if vignetteEnabled is set to true.
  8102. */
  8103. vignetteColor: Color4;
  8104. /**
  8105. * Camera field of view used by the Vignette effect.
  8106. */
  8107. vignetteCameraFov: number;
  8108. private _vignetteBlendMode;
  8109. /**
  8110. * Gets the vignette blend mode allowing different kind of effect.
  8111. */
  8112. /**
  8113. * Sets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. vignetteBlendMode: number;
  8116. private _vignetteEnabled;
  8117. /**
  8118. * Gets wether the vignette effect is enabled.
  8119. */
  8120. /**
  8121. * Sets wether the vignette effect is enabled.
  8122. */
  8123. vignetteEnabled: boolean;
  8124. private _applyByPostProcess;
  8125. /**
  8126. * Gets wether the image processing is applied through a post process or not.
  8127. */
  8128. /**
  8129. * Sets wether the image processing is applied through a post process or not.
  8130. */
  8131. applyByPostProcess: boolean;
  8132. private _isEnabled;
  8133. /**
  8134. * Gets wether the image processing is enabled or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is enabled or not.
  8138. */
  8139. isEnabled: boolean;
  8140. /**
  8141. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8142. */
  8143. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8144. /**
  8145. * Method called each time the image processing information changes requires to recompile the effect.
  8146. */
  8147. protected _updateParameters(): void;
  8148. /**
  8149. * Gets the current class name.
  8150. * @return "ImageProcessingConfiguration"
  8151. */
  8152. getClassName(): string;
  8153. /**
  8154. * Prepare the list of uniforms associated with the Image Processing effects.
  8155. * @param uniforms The list of uniforms used in the effect
  8156. * @param defines the list of defines currently in use
  8157. */
  8158. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8159. /**
  8160. * Prepare the list of samplers associated with the Image Processing effects.
  8161. * @param samplersList The list of uniforms used in the effect
  8162. * @param defines the list of defines currently in use
  8163. */
  8164. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8165. /**
  8166. * Prepare the list of defines associated to the shader.
  8167. * @param defines the list of defines to complete
  8168. * @param forPostProcess Define if we are currently in post process mode or not
  8169. */
  8170. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8171. /**
  8172. * Returns true if all the image processing information are ready.
  8173. * @returns True if ready, otherwise, false
  8174. */
  8175. isReady(): boolean;
  8176. /**
  8177. * Binds the image processing to the shader.
  8178. * @param effect The effect to bind to
  8179. * @param aspectRatio Define the current aspect ratio of the effect
  8180. */
  8181. bind(effect: Effect, aspectRatio?: number): void;
  8182. /**
  8183. * Clones the current image processing instance.
  8184. * @return The cloned image processing
  8185. */
  8186. clone(): ImageProcessingConfiguration;
  8187. /**
  8188. * Serializes the current image processing instance to a json representation.
  8189. * @return a JSON representation
  8190. */
  8191. serialize(): any;
  8192. /**
  8193. * Parses the image processing from a json representation.
  8194. * @param source the JSON source to parse
  8195. * @return The parsed image processing
  8196. */
  8197. static Parse(source: any): ImageProcessingConfiguration;
  8198. private static _VIGNETTEMODE_MULTIPLY;
  8199. private static _VIGNETTEMODE_OPAQUE;
  8200. /**
  8201. * Used to apply the vignette as a mix with the pixel color.
  8202. */
  8203. static readonly VIGNETTEMODE_MULTIPLY: number;
  8204. /**
  8205. * Used to apply the vignette as a replacement of the pixel color.
  8206. */
  8207. static readonly VIGNETTEMODE_OPAQUE: number;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** @hidden */
  8212. export var postprocessVertexShader: {
  8213. name: string;
  8214. shader: string;
  8215. };
  8216. }
  8217. declare module BABYLON {
  8218. /** Defines supported spaces */
  8219. export enum Space {
  8220. /** Local (object) space */
  8221. LOCAL = 0,
  8222. /** World space */
  8223. WORLD = 1,
  8224. /** Bone space */
  8225. BONE = 2
  8226. }
  8227. /** Defines the 3 main axes */
  8228. export class Axis {
  8229. /** X axis */
  8230. static X: Vector3;
  8231. /** Y axis */
  8232. static Y: Vector3;
  8233. /** Z axis */
  8234. static Z: Vector3;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8240. * This is the base of the follow, arc rotate cameras and Free camera
  8241. * @see http://doc.babylonjs.com/features/cameras
  8242. */
  8243. export class TargetCamera extends Camera {
  8244. private static _RigCamTransformMatrix;
  8245. private static _TargetTransformMatrix;
  8246. private static _TargetFocalPoint;
  8247. /**
  8248. * Define the current direction the camera is moving to
  8249. */
  8250. cameraDirection: Vector3;
  8251. /**
  8252. * Define the current rotation the camera is rotating to
  8253. */
  8254. cameraRotation: Vector2;
  8255. /**
  8256. * When set, the up vector of the camera will be updated by the rotation of the camera
  8257. */
  8258. updateUpVectorFromRotation: boolean;
  8259. private _tmpQuaternion;
  8260. /**
  8261. * Define the current rotation of the camera
  8262. */
  8263. rotation: Vector3;
  8264. /**
  8265. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8266. */
  8267. rotationQuaternion: Quaternion;
  8268. /**
  8269. * Define the current speed of the camera
  8270. */
  8271. speed: number;
  8272. /**
  8273. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8274. * around all axis.
  8275. */
  8276. noRotationConstraint: boolean;
  8277. /**
  8278. * Define the current target of the camera as an object or a position.
  8279. */
  8280. lockedTarget: any;
  8281. /** @hidden */
  8282. _currentTarget: Vector3;
  8283. /** @hidden */
  8284. _initialFocalDistance: number;
  8285. /** @hidden */
  8286. _viewMatrix: Matrix;
  8287. /** @hidden */
  8288. _camMatrix: Matrix;
  8289. /** @hidden */
  8290. _cameraTransformMatrix: Matrix;
  8291. /** @hidden */
  8292. _cameraRotationMatrix: Matrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /**
  8343. * Defines the target the camera should look at.
  8344. * @param target Defines the new target as a Vector or a mesh
  8345. */
  8346. setTarget(target: Vector3): void;
  8347. /**
  8348. * Return the current target position of the camera. This value is expressed in local space.
  8349. * @returns the target position
  8350. */
  8351. getTarget(): Vector3;
  8352. /** @hidden */
  8353. _decideIfNeedsToMove(): boolean;
  8354. /** @hidden */
  8355. _updatePosition(): void;
  8356. /** @hidden */
  8357. _checkInputs(): void;
  8358. protected _updateCameraRotationMatrix(): void;
  8359. /**
  8360. * 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)
  8361. * @returns the current camera
  8362. */
  8363. private _rotateUpVectorWithCameraRotationMatrix;
  8364. private _cachedRotationZ;
  8365. private _cachedQuaternionRotationZ;
  8366. /** @hidden */
  8367. _getViewMatrix(): Matrix;
  8368. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8369. /**
  8370. * @hidden
  8371. */
  8372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8373. /**
  8374. * @hidden
  8375. */
  8376. _updateRigCameras(): void;
  8377. private _getRigCamPositionAndTarget;
  8378. /**
  8379. * Gets the current object class name.
  8380. * @return the class name
  8381. */
  8382. getClassName(): string;
  8383. }
  8384. }
  8385. declare module BABYLON {
  8386. /**
  8387. * Gather the list of keyboard event types as constants.
  8388. */
  8389. export class KeyboardEventTypes {
  8390. /**
  8391. * The keydown event is fired when a key becomes active (pressed).
  8392. */
  8393. static readonly KEYDOWN: number;
  8394. /**
  8395. * The keyup event is fired when a key has been released.
  8396. */
  8397. static readonly KEYUP: number;
  8398. }
  8399. /**
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. */
  8402. export class KeyboardInfo {
  8403. /**
  8404. * Defines the type of event (KeyboardEventTypes)
  8405. */
  8406. type: number;
  8407. /**
  8408. * Defines the related dom event
  8409. */
  8410. event: KeyboardEvent;
  8411. /**
  8412. * Instantiates a new keyboard info.
  8413. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8414. * @param type Defines the type of event (KeyboardEventTypes)
  8415. * @param event Defines the related dom event
  8416. */
  8417. constructor(
  8418. /**
  8419. * Defines the type of event (KeyboardEventTypes)
  8420. */
  8421. type: number,
  8422. /**
  8423. * Defines the related dom event
  8424. */
  8425. event: KeyboardEvent);
  8426. }
  8427. /**
  8428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8430. */
  8431. export class KeyboardInfoPre extends KeyboardInfo {
  8432. /**
  8433. * Defines the type of event (KeyboardEventTypes)
  8434. */
  8435. type: number;
  8436. /**
  8437. * Defines the related dom event
  8438. */
  8439. event: KeyboardEvent;
  8440. /**
  8441. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8442. */
  8443. skipOnPointerObservable: boolean;
  8444. /**
  8445. * Instantiates a new keyboard pre info.
  8446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8447. * @param type Defines the type of event (KeyboardEventTypes)
  8448. * @param event Defines the related dom event
  8449. */
  8450. constructor(
  8451. /**
  8452. * Defines the type of event (KeyboardEventTypes)
  8453. */
  8454. type: number,
  8455. /**
  8456. * Defines the related dom event
  8457. */
  8458. event: KeyboardEvent);
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * Manage the keyboard inputs to control the movement of a free camera.
  8464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8465. */
  8466. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8467. /**
  8468. * Defines the camera the input is attached to.
  8469. */
  8470. camera: FreeCamera;
  8471. /**
  8472. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8473. */
  8474. keysUp: number[];
  8475. /**
  8476. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8477. */
  8478. keysDown: number[];
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8481. */
  8482. keysLeft: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8485. */
  8486. keysRight: number[];
  8487. private _keys;
  8488. private _onCanvasBlurObserver;
  8489. private _onKeyboardObserver;
  8490. private _engine;
  8491. private _scene;
  8492. /**
  8493. * Attach the input controls to a specific dom element to get the input from.
  8494. * @param element Defines the element the controls should be listened from
  8495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8496. */
  8497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8498. /**
  8499. * Detach the current controls from the specified dom element.
  8500. * @param element Defines the element to stop listening the inputs from
  8501. */
  8502. detachControl(element: Nullable<HTMLElement>): void;
  8503. /**
  8504. * Update the current camera state depending on the inputs that have been used this frame.
  8505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8506. */
  8507. checkInputs(): void;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /** @hidden */
  8514. _onLostFocus(): void;
  8515. /**
  8516. * Get the friendly name associated with the input class.
  8517. * @returns the input friendly name
  8518. */
  8519. getSimpleName(): string;
  8520. }
  8521. }
  8522. declare module BABYLON {
  8523. /**
  8524. * Interface describing all the common properties and methods a shadow light needs to implement.
  8525. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8526. * as well as binding the different shadow properties to the effects.
  8527. */
  8528. export interface IShadowLight extends Light {
  8529. /**
  8530. * The light id in the scene (used in scene.findLighById for instance)
  8531. */
  8532. id: string;
  8533. /**
  8534. * The position the shdow will be casted from.
  8535. */
  8536. position: Vector3;
  8537. /**
  8538. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8539. */
  8540. direction: Vector3;
  8541. /**
  8542. * The transformed position. Position of the light in world space taking parenting in account.
  8543. */
  8544. transformedPosition: Vector3;
  8545. /**
  8546. * The transformed direction. Direction of the light in world space taking parenting in account.
  8547. */
  8548. transformedDirection: Vector3;
  8549. /**
  8550. * The friendly name of the light in the scene.
  8551. */
  8552. name: string;
  8553. /**
  8554. * Defines the shadow projection clipping minimum z value.
  8555. */
  8556. shadowMinZ: number;
  8557. /**
  8558. * Defines the shadow projection clipping maximum z value.
  8559. */
  8560. shadowMaxZ: number;
  8561. /**
  8562. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8563. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8564. */
  8565. computeTransformedInformation(): boolean;
  8566. /**
  8567. * Gets the scene the light belongs to.
  8568. * @returns The scene
  8569. */
  8570. getScene(): Scene;
  8571. /**
  8572. * Callback defining a custom Projection Matrix Builder.
  8573. * This can be used to override the default projection matrix computation.
  8574. */
  8575. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8576. /**
  8577. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8578. * @param matrix The materix to updated with the projection information
  8579. * @param viewMatrix The transform matrix of the light
  8580. * @param renderList The list of mesh to render in the map
  8581. * @returns The current light
  8582. */
  8583. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8584. /**
  8585. * Gets the current depth scale used in ESM.
  8586. * @returns The scale
  8587. */
  8588. getDepthScale(): number;
  8589. /**
  8590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8591. * @returns true if a cube texture needs to be use
  8592. */
  8593. needCube(): boolean;
  8594. /**
  8595. * Detects if the projection matrix requires to be recomputed this frame.
  8596. * @returns true if it requires to be recomputed otherwise, false.
  8597. */
  8598. needProjectionMatrixCompute(): boolean;
  8599. /**
  8600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8601. */
  8602. forceProjectionMatrixCompute(): void;
  8603. /**
  8604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8607. */
  8608. getShadowDirection(faceIndex?: number): Vector3;
  8609. /**
  8610. * Gets the minZ used for shadow according to both the scene and the light.
  8611. * @param activeCamera The camera we are returning the min for
  8612. * @returns the depth min z
  8613. */
  8614. getDepthMinZ(activeCamera: Camera): number;
  8615. /**
  8616. * Gets the maxZ used for shadow according to both the scene and the light.
  8617. * @param activeCamera The camera we are returning the max for
  8618. * @returns the depth max z
  8619. */
  8620. getDepthMaxZ(activeCamera: Camera): number;
  8621. }
  8622. /**
  8623. * Base implementation IShadowLight
  8624. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8625. */
  8626. export abstract class ShadowLight extends Light implements IShadowLight {
  8627. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8628. protected _position: Vector3;
  8629. protected _setPosition(value: Vector3): void;
  8630. /**
  8631. * Sets the position the shadow will be casted from. Also use as the light position for both
  8632. * point and spot lights.
  8633. */
  8634. /**
  8635. * Sets the position the shadow will be casted from. Also use as the light position for both
  8636. * point and spot lights.
  8637. */
  8638. position: Vector3;
  8639. protected _direction: Vector3;
  8640. protected _setDirection(value: Vector3): void;
  8641. /**
  8642. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8643. * Also use as the light direction on spot and directional lights.
  8644. */
  8645. /**
  8646. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8647. * Also use as the light direction on spot and directional lights.
  8648. */
  8649. direction: Vector3;
  8650. private _shadowMinZ;
  8651. /**
  8652. * Gets the shadow projection clipping minimum z value.
  8653. */
  8654. /**
  8655. * Sets the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. private _shadowMaxZ;
  8659. /**
  8660. * Sets the shadow projection clipping maximum z value.
  8661. */
  8662. /**
  8663. * Gets the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Callback defining a custom Projection Matrix Builder.
  8668. * This can be used to override the default projection matrix computation.
  8669. */
  8670. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8671. /**
  8672. * The transformed position. Position of the light in world space taking parenting in account.
  8673. */
  8674. transformedPosition: Vector3;
  8675. /**
  8676. * The transformed direction. Direction of the light in world space taking parenting in account.
  8677. */
  8678. transformedDirection: Vector3;
  8679. private _needProjectionMatrixCompute;
  8680. /**
  8681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8683. */
  8684. computeTransformedInformation(): boolean;
  8685. /**
  8686. * Return the depth scale used for the shadow map.
  8687. * @returns the depth scale.
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8692. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8693. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8694. */
  8695. getShadowDirection(faceIndex?: number): Vector3;
  8696. /**
  8697. * Returns the ShadowLight absolute position in the World.
  8698. * @returns the position vector in world space
  8699. */
  8700. getAbsolutePosition(): Vector3;
  8701. /**
  8702. * Sets the ShadowLight direction toward the passed target.
  8703. * @param target The point to target in local space
  8704. * @returns the updated ShadowLight direction
  8705. */
  8706. setDirectionToTarget(target: Vector3): Vector3;
  8707. /**
  8708. * Returns the light rotation in euler definition.
  8709. * @returns the x y z rotation in local space.
  8710. */
  8711. getRotation(): Vector3;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _isSynchronized(): boolean;
  8730. /**
  8731. * Computes the world matrix of the node
  8732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8733. * @returns the world matrix
  8734. */
  8735. computeWorldMatrix(force?: boolean): Matrix;
  8736. /**
  8737. * Gets the minZ used for shadow according to both the scene and the light.
  8738. * @param activeCamera The camera we are returning the min for
  8739. * @returns the depth min z
  8740. */
  8741. getDepthMinZ(activeCamera: Camera): number;
  8742. /**
  8743. * Gets the maxZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the max for
  8745. * @returns the depth max z
  8746. */
  8747. getDepthMaxZ(activeCamera: Camera): number;
  8748. /**
  8749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8750. * @param matrix The materix to updated with the projection information
  8751. * @param viewMatrix The transform matrix of the light
  8752. * @param renderList The list of mesh to render in the map
  8753. * @returns The current light
  8754. */
  8755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * "Static Class" containing the most commonly used helper while dealing with material for
  8761. * rendering purpose.
  8762. *
  8763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8764. *
  8765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8766. */
  8767. export class MaterialHelper {
  8768. /**
  8769. * Bind the current view position to an effect.
  8770. * @param effect The effect to be bound
  8771. * @param scene The scene the eyes position is used from
  8772. */
  8773. static BindEyePosition(effect: Effect, scene: Scene): void;
  8774. /**
  8775. * Helps preparing the defines values about the UVs in used in the effect.
  8776. * UVs are shared as much as we can accross channels in the shaders.
  8777. * @param texture The texture we are preparing the UVs for
  8778. * @param defines The defines to update
  8779. * @param key The channel key "diffuse", "specular"... used in the shader
  8780. */
  8781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8782. /**
  8783. * Binds a texture matrix value to its corrsponding uniform
  8784. * @param texture The texture to bind the matrix for
  8785. * @param uniformBuffer The uniform buffer receivin the data
  8786. * @param key The channel key "diffuse", "specular"... used in the shader
  8787. */
  8788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8789. /**
  8790. * Gets the current status of the fog (should it be enabled?)
  8791. * @param mesh defines the mesh to evaluate for fog support
  8792. * @param scene defines the hosting scene
  8793. * @returns true if fog must be enabled
  8794. */
  8795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8796. /**
  8797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8798. * @param mesh defines the current mesh
  8799. * @param scene defines the current scene
  8800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8801. * @param pointsCloud defines if point cloud rendering has to be turned on
  8802. * @param fogEnabled defines if fog has to be turned on
  8803. * @param alphaTest defines if alpha testing has to be turned on
  8804. * @param defines defines the current list of defines
  8805. */
  8806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8809. * @param scene defines the current scene
  8810. * @param engine defines the current engine
  8811. * @param defines specifies the list of active defines
  8812. * @param useInstances defines if instances have to be turned on
  8813. * @param useClipPlane defines if clip plane have to be turned on
  8814. */
  8815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8816. /**
  8817. * Prepares the defines for bones
  8818. * @param mesh The mesh containing the geometry data we will draw
  8819. * @param defines The defines to update
  8820. */
  8821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8822. /**
  8823. * Prepares the defines for morph targets
  8824. * @param mesh The mesh containing the geometry data we will draw
  8825. * @param defines The defines to update
  8826. */
  8827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8828. /**
  8829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8830. * @param mesh The mesh containing the geometry data we will draw
  8831. * @param defines The defines to update
  8832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8833. * @param useBones Precise whether bones should be used or not (override mesh info)
  8834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8836. * @returns false if defines are considered not dirty and have not been checked
  8837. */
  8838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8839. /**
  8840. * Prepares the defines related to multiview
  8841. * @param scene The scene we are intending to draw
  8842. * @param defines The defines to update
  8843. */
  8844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8845. /**
  8846. * Prepares the defines related to the light information passed in parameter
  8847. * @param scene The scene we are intending to draw
  8848. * @param mesh The mesh the effect is compiling for
  8849. * @param light The light the effect is compiling for
  8850. * @param lightIndex The index of the light
  8851. * @param defines The defines to update
  8852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8853. * @param state Defines the current state regarding what is needed (normals, etc...)
  8854. */
  8855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8856. needNormals: boolean;
  8857. needRebuild: boolean;
  8858. shadowEnabled: boolean;
  8859. specularEnabled: boolean;
  8860. lightmapMode: boolean;
  8861. }): void;
  8862. /**
  8863. * Prepares the defines related to the light information passed in parameter
  8864. * @param scene The scene we are intending to draw
  8865. * @param mesh The mesh the effect is compiling for
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8870. * @returns true if normals will be required for the rest of the effect
  8871. */
  8872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8873. /**
  8874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8875. * @param lightIndex defines the light index
  8876. * @param uniformsList The uniform list
  8877. * @param samplersList The sampler list
  8878. * @param projectedLightTexture defines if projected texture must be used
  8879. * @param uniformBuffersList defines an optional list of uniform buffers
  8880. */
  8881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8882. /**
  8883. * Prepares the uniforms and samplers list to be used in the effect
  8884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8885. * @param samplersList The sampler list
  8886. * @param defines The defines helping in the list generation
  8887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8888. */
  8889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8890. /**
  8891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8892. * @param defines The defines to update while falling back
  8893. * @param fallbacks The authorized effect fallbacks
  8894. * @param maxSimultaneousLights The maximum number of lights allowed
  8895. * @param rank the current rank of the Effect
  8896. * @returns The newly affected rank
  8897. */
  8898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8899. private static _TmpMorphInfluencers;
  8900. /**
  8901. * Prepares the list of attributes required for morph targets according to the effect defines.
  8902. * @param attribs The current list of supported attribs
  8903. * @param mesh The mesh to prepare the morph targets attributes for
  8904. * @param influencers The number of influencers
  8905. */
  8906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8907. /**
  8908. * Prepares the list of attributes required for morph targets according to the effect defines.
  8909. * @param attribs The current list of supported attribs
  8910. * @param mesh The mesh to prepare the morph targets attributes for
  8911. * @param defines The current Defines of the effect
  8912. */
  8913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the list of attributes required for bones according to the effect defines.
  8916. * @param attribs The current list of supported attribs
  8917. * @param mesh The mesh to prepare the bones attributes for
  8918. * @param defines The current Defines of the effect
  8919. * @param fallbacks The current efffect fallback strategy
  8920. */
  8921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8922. /**
  8923. * Check and prepare the list of attributes required for instances according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param defines The current MaterialDefines of the effect
  8926. */
  8927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8928. /**
  8929. * Add the list of attributes required for instances to the attribs array.
  8930. * @param attribs The current list of supported attribs
  8931. */
  8932. static PushAttributesForInstances(attribs: string[]): void;
  8933. /**
  8934. * Binds the light shadow information to the effect for the given mesh.
  8935. * @param light The light containing the generator
  8936. * @param scene The scene the lights belongs to
  8937. * @param mesh The mesh we are binding the information to render
  8938. * @param lightIndex The light index in the effect used to render the mesh
  8939. * @param effect The effect we are binding the data to
  8940. */
  8941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8942. /**
  8943. * Binds the light information to the effect.
  8944. * @param light The light containing the generator
  8945. * @param effect The effect we are binding the data to
  8946. * @param lightIndex The light index in the effect used to render
  8947. */
  8948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8949. /**
  8950. * Binds the lights information from the scene to the effect for the given mesh.
  8951. * @param light Light to bind
  8952. * @param lightIndex Light index
  8953. * @param scene The scene where the light belongs to
  8954. * @param mesh The mesh we are binding the information to render
  8955. * @param effect The effect we are binding the data to
  8956. * @param useSpecular Defines if specular is supported
  8957. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8958. */
  8959. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8960. /**
  8961. * Binds the lights information from the scene to the effect for the given mesh.
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param effect The effect we are binding the data to
  8965. * @param defines The generated defines for the effect
  8966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8967. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8968. */
  8969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8970. private static _tempFogColor;
  8971. /**
  8972. * Binds the fog information from the scene to the effect for the given mesh.
  8973. * @param scene The scene the lights belongs to
  8974. * @param mesh The mesh we are binding the information to render
  8975. * @param effect The effect we are binding the data to
  8976. * @param linearSpace Defines if the fog effect is applied in linear space
  8977. */
  8978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8979. /**
  8980. * Binds the bones information from the mesh to the effect.
  8981. * @param mesh The mesh we are binding the information to render
  8982. * @param effect The effect we are binding the data to
  8983. */
  8984. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8985. /**
  8986. * Binds the morph targets information from the mesh to the effect.
  8987. * @param abstractMesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. */
  8990. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8991. /**
  8992. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8993. * @param defines The generated defines used in the effect
  8994. * @param effect The effect we are binding the data to
  8995. * @param scene The scene we are willing to render with logarithmic scale for
  8996. */
  8997. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8998. /**
  8999. * Binds the clip plane information from the scene to the effect.
  9000. * @param scene The scene the clip plane information are extracted from
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindClipPlane(effect: Effect, scene: Scene): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var packingFunctions: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapPixelShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var bonesDeclaration: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var morphTargetsVertexGlobalDeclaration: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var morphTargetsVertexDeclaration: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var instancesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var helperFunctions: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertex: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesVertex: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var bonesVertex: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var shadowMapVertexShader: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var depthBoxBlurPixelShader: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9093. */
  9094. export interface ICustomShaderOptions {
  9095. /**
  9096. * Gets or sets the custom shader name to use
  9097. */
  9098. shaderName: string;
  9099. /**
  9100. * The list of attribute names used in the shader
  9101. */
  9102. attributes?: string[];
  9103. /**
  9104. * The list of unifrom names used in the shader
  9105. */
  9106. uniforms?: string[];
  9107. /**
  9108. * The list of sampler names used in the shader
  9109. */
  9110. samplers?: string[];
  9111. /**
  9112. * The list of defines used in the shader
  9113. */
  9114. defines?: string[];
  9115. }
  9116. /**
  9117. * Interface to implement to create a shadow generator compatible with BJS.
  9118. */
  9119. export interface IShadowGenerator {
  9120. /**
  9121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9122. * @returns The render target texture if present otherwise, null
  9123. */
  9124. getShadowMap(): Nullable<RenderTargetTexture>;
  9125. /**
  9126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9127. * @returns The render target texture if the shadow map is present otherwise, null
  9128. */
  9129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9132. * @param subMesh The submesh we want to render in the shadow map
  9133. * @param useInstances Defines wether will draw in the map using instances
  9134. * @returns true if ready otherwise, false
  9135. */
  9136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9137. /**
  9138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9139. * @param defines Defines of the material we want to update
  9140. * @param lightIndex Index of the light in the enabled light list of the material
  9141. */
  9142. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9143. /**
  9144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9145. * defined in the generator but impacting the effect).
  9146. * It implies the unifroms available on the materials are the standard BJS ones.
  9147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9148. * @param effect The effect we are binfing the information for
  9149. */
  9150. bindShadowLight(lightIndex: string, effect: Effect): void;
  9151. /**
  9152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9153. * (eq to shadow prjection matrix * light transform matrix)
  9154. * @returns The transform matrix used to create the shadow map
  9155. */
  9156. getTransformMatrix(): Matrix;
  9157. /**
  9158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9159. * Cube and 2D textures for instance.
  9160. */
  9161. recreateShadowMap(): void;
  9162. /**
  9163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9164. * @param onCompiled Callback triggered at the and of the effects compilation
  9165. * @param options Sets of optional options forcing the compilation with different modes
  9166. */
  9167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9168. useInstances: boolean;
  9169. }>): void;
  9170. /**
  9171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9172. * @param options Sets of optional options forcing the compilation with different modes
  9173. * @returns A promise that resolves when the compilation completes
  9174. */
  9175. forceCompilationAsync(options?: Partial<{
  9176. useInstances: boolean;
  9177. }>): Promise<void>;
  9178. /**
  9179. * Serializes the shadow generator setup to a json object.
  9180. * @returns The serialized JSON object
  9181. */
  9182. serialize(): any;
  9183. /**
  9184. * Disposes the Shadow map and related Textures and effects.
  9185. */
  9186. dispose(): void;
  9187. }
  9188. /**
  9189. * Default implementation IShadowGenerator.
  9190. * This is the main object responsible of generating shadows in the framework.
  9191. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9192. */
  9193. export class ShadowGenerator implements IShadowGenerator {
  9194. /**
  9195. * Shadow generator mode None: no filtering applied.
  9196. */
  9197. static readonly FILTER_NONE: number;
  9198. /**
  9199. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9201. */
  9202. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9203. /**
  9204. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9205. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9206. */
  9207. static readonly FILTER_POISSONSAMPLING: number;
  9208. /**
  9209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9215. * edge artifacts on steep falloff.
  9216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9217. */
  9218. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9219. /**
  9220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9221. * edge artifacts on steep falloff.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode PCF: Percentage Closer Filtering
  9227. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9228. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9229. */
  9230. static readonly FILTER_PCF: number;
  9231. /**
  9232. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9233. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9234. * Contact Hardening
  9235. */
  9236. static readonly FILTER_PCSS: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * Highest Quality.
  9240. *
  9241. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9242. *
  9243. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9244. */
  9245. static readonly QUALITY_HIGH: number;
  9246. /**
  9247. * Reserved for PCF and PCSS
  9248. * Good tradeoff for quality/perf cross devices
  9249. *
  9250. * Execute PCF on a 3*3 kernel.
  9251. *
  9252. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9253. */
  9254. static readonly QUALITY_MEDIUM: number;
  9255. /**
  9256. * Reserved for PCF and PCSS
  9257. * The lowest quality but the fastest.
  9258. *
  9259. * Execute PCF on a 1*1 kernel.
  9260. *
  9261. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9262. */
  9263. static readonly QUALITY_LOW: number;
  9264. /** Gets or sets the custom shader name to use */
  9265. customShaderOptions: ICustomShaderOptions;
  9266. /**
  9267. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9268. */
  9269. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9270. /**
  9271. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9272. */
  9273. onAfterShadowMapRenderObservable: Observable<Effect>;
  9274. /**
  9275. * Observable triggered before a mesh is rendered in the shadow map.
  9276. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9277. */
  9278. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9279. /**
  9280. * Observable triggered after a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9282. */
  9283. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. private _bias;
  9285. /**
  9286. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9287. */
  9288. /**
  9289. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. bias: number;
  9292. private _normalBias;
  9293. /**
  9294. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9295. */
  9296. /**
  9297. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. normalBias: number;
  9300. private _blurBoxOffset;
  9301. /**
  9302. * Gets the blur box offset: offset applied during the blur pass.
  9303. * Only useful if useKernelBlur = false
  9304. */
  9305. /**
  9306. * Sets the blur box offset: offset applied during the blur pass.
  9307. * Only useful if useKernelBlur = false
  9308. */
  9309. blurBoxOffset: number;
  9310. private _blurScale;
  9311. /**
  9312. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9313. * 2 means half of the size.
  9314. */
  9315. /**
  9316. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9317. * 2 means half of the size.
  9318. */
  9319. blurScale: number;
  9320. private _blurKernel;
  9321. /**
  9322. * Gets the blur kernel: kernel size of the blur pass.
  9323. * Only useful if useKernelBlur = true
  9324. */
  9325. /**
  9326. * Sets the blur kernel: kernel size of the blur pass.
  9327. * Only useful if useKernelBlur = true
  9328. */
  9329. blurKernel: number;
  9330. private _useKernelBlur;
  9331. /**
  9332. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9334. */
  9335. /**
  9336. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9337. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9338. */
  9339. useKernelBlur: boolean;
  9340. private _depthScale;
  9341. /**
  9342. * Gets the depth scale used in ESM mode.
  9343. */
  9344. /**
  9345. * Sets the depth scale used in ESM mode.
  9346. * This can override the scale stored on the light.
  9347. */
  9348. depthScale: number;
  9349. private _filter;
  9350. /**
  9351. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9352. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9353. */
  9354. /**
  9355. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9356. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9357. */
  9358. filter: number;
  9359. /**
  9360. * Gets if the current filter is set to Poisson Sampling.
  9361. */
  9362. /**
  9363. * Sets the current filter to Poisson Sampling.
  9364. */
  9365. usePoissonSampling: boolean;
  9366. /**
  9367. * Gets if the current filter is set to ESM.
  9368. */
  9369. /**
  9370. * Sets the current filter is to ESM.
  9371. */
  9372. useExponentialShadowMap: boolean;
  9373. /**
  9374. * Gets if the current filter is set to filtered ESM.
  9375. */
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. useBlurExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. /**
  9385. * Sets the current filter to "close ESM" (using the inverse of the
  9386. * exponential to prevent steep falloff artifacts).
  9387. */
  9388. useCloseExponentialShadowMap: boolean;
  9389. /**
  9390. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. /**
  9394. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9395. * exponential to prevent steep falloff artifacts).
  9396. */
  9397. useBlurCloseExponentialShadowMap: boolean;
  9398. /**
  9399. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9400. */
  9401. /**
  9402. * Sets the current filter to "PCF" (percentage closer filtering).
  9403. */
  9404. usePercentageCloserFiltering: boolean;
  9405. private _filteringQuality;
  9406. /**
  9407. * Gets the PCF or PCSS Quality.
  9408. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9409. */
  9410. /**
  9411. * Sets the PCF or PCSS Quality.
  9412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9413. */
  9414. filteringQuality: number;
  9415. /**
  9416. * Gets if the current filter is set to "PCSS" (contact hardening).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCSS" (contact hardening).
  9420. */
  9421. useContactHardeningShadow: boolean;
  9422. private _contactHardeningLightSizeUVRatio;
  9423. /**
  9424. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9425. * Using a ratio helps keeping shape stability independently of the map size.
  9426. *
  9427. * It does not account for the light projection as it was having too much
  9428. * instability during the light setup or during light position changes.
  9429. *
  9430. * Only valid if useContactHardeningShadow is true.
  9431. */
  9432. /**
  9433. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9434. * Using a ratio helps keeping shape stability independently of the map size.
  9435. *
  9436. * It does not account for the light projection as it was having too much
  9437. * instability during the light setup or during light position changes.
  9438. *
  9439. * Only valid if useContactHardeningShadow is true.
  9440. */
  9441. contactHardeningLightSizeUVRatio: number;
  9442. private _darkness;
  9443. /** Gets or sets the actual darkness of a shadow */
  9444. darkness: number;
  9445. /**
  9446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9447. * 0 means strongest and 1 would means no shadow.
  9448. * @returns the darkness.
  9449. */
  9450. getDarkness(): number;
  9451. /**
  9452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9454. * @returns the shadow generator allowing fluent coding.
  9455. */
  9456. setDarkness(darkness: number): ShadowGenerator;
  9457. private _transparencyShadow;
  9458. /** Gets or sets the ability to have transparent shadow */
  9459. transparencyShadow: boolean;
  9460. /**
  9461. * Sets the ability to have transparent shadow (boolean).
  9462. * @param transparent True if transparent else False
  9463. * @returns the shadow generator allowing fluent coding
  9464. */
  9465. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9466. private _shadowMap;
  9467. private _shadowMap2;
  9468. /**
  9469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9470. * @returns The render target texture if present otherwise, null
  9471. */
  9472. getShadowMap(): Nullable<RenderTargetTexture>;
  9473. /**
  9474. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9475. * @returns The render target texture if the shadow map is present otherwise, null
  9476. */
  9477. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the class name of that object
  9480. * @returns "ShadowGenerator"
  9481. */
  9482. getClassName(): string;
  9483. /**
  9484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9485. * @param mesh Mesh to add
  9486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9487. * @returns the Shadow Generator itself
  9488. */
  9489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9490. /**
  9491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9492. * @param mesh Mesh to remove
  9493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9494. * @returns the Shadow Generator itself
  9495. */
  9496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9497. /**
  9498. * Controls the extent to which the shadows fade out at the edge of the frustum
  9499. * Used only by directionals and spots
  9500. */
  9501. frustumEdgeFalloff: number;
  9502. private _light;
  9503. /**
  9504. * Returns the associated light object.
  9505. * @returns the light generating the shadow
  9506. */
  9507. getLight(): IShadowLight;
  9508. /**
  9509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9511. * It might on the other hand introduce peter panning.
  9512. */
  9513. forceBackFacesOnly: boolean;
  9514. private _scene;
  9515. private _lightDirection;
  9516. private _effect;
  9517. private _viewMatrix;
  9518. private _projectionMatrix;
  9519. private _transformMatrix;
  9520. private _cachedPosition;
  9521. private _cachedDirection;
  9522. private _cachedDefines;
  9523. private _currentRenderID;
  9524. private _boxBlurPostprocess;
  9525. private _kernelBlurXPostprocess;
  9526. private _kernelBlurYPostprocess;
  9527. private _blurPostProcesses;
  9528. private _mapSize;
  9529. private _currentFaceIndex;
  9530. private _currentFaceIndexCache;
  9531. private _textureType;
  9532. private _defaultTextureMatrix;
  9533. /** @hidden */
  9534. static _SceneComponentInitialization: (scene: Scene) => void;
  9535. /**
  9536. * Creates a ShadowGenerator object.
  9537. * A ShadowGenerator is the required tool to use the shadows.
  9538. * Each light casting shadows needs to use its own ShadowGenerator.
  9539. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9541. * @param light The light object generating the shadows.
  9542. * @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.
  9543. */
  9544. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9545. private _initializeGenerator;
  9546. private _initializeShadowMap;
  9547. private _initializeBlurRTTAndPostProcesses;
  9548. private _renderForShadowMap;
  9549. private _renderSubMeshForShadowMap;
  9550. private _applyFilterValues;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9569. * @param subMesh The submesh we want to render in the shadow map
  9570. * @param useInstances Defines wether will draw in the map using instances
  9571. * @returns true if ready otherwise, false
  9572. */
  9573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9574. /**
  9575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9576. * @param defines Defines of the material we want to update
  9577. * @param lightIndex Index of the light in the enabled light list of the material
  9578. */
  9579. prepareDefines(defines: any, lightIndex: number): void;
  9580. /**
  9581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9582. * defined in the generator but impacting the effect).
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. private _disposeBlurPostProcesses;
  9599. private _disposeRTTandPostProcesses;
  9600. /**
  9601. * Disposes the ShadowGenerator.
  9602. * Returns nothing.
  9603. */
  9604. dispose(): void;
  9605. /**
  9606. * Serializes the shadow generator setup to a json object.
  9607. * @returns The serialized JSON object
  9608. */
  9609. serialize(): any;
  9610. /**
  9611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9612. * @param parsedShadowGenerator The JSON object to parse
  9613. * @param scene The scene to create the shadow map for
  9614. * @returns The parsed shadow generator
  9615. */
  9616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9617. }
  9618. }
  9619. declare module BABYLON {
  9620. /**
  9621. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9622. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9623. * 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.
  9624. */
  9625. export abstract class Light extends Node {
  9626. /**
  9627. * Falloff Default: light is falling off following the material specification:
  9628. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9629. */
  9630. static readonly FALLOFF_DEFAULT: number;
  9631. /**
  9632. * Falloff Physical: light is falling off following the inverse squared distance law.
  9633. */
  9634. static readonly FALLOFF_PHYSICAL: number;
  9635. /**
  9636. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9637. * to enhance interoperability with other engines.
  9638. */
  9639. static readonly FALLOFF_GLTF: number;
  9640. /**
  9641. * Falloff Standard: light is falling off like in the standard material
  9642. * to enhance interoperability with other materials.
  9643. */
  9644. static readonly FALLOFF_STANDARD: number;
  9645. /**
  9646. * If every light affecting the material is in this lightmapMode,
  9647. * material.lightmapTexture adds or multiplies
  9648. * (depends on material.useLightmapAsShadowmap)
  9649. * after every other light calculations.
  9650. */
  9651. static readonly LIGHTMAP_DEFAULT: number;
  9652. /**
  9653. * material.lightmapTexture as only diffuse lighting from this light
  9654. * adds only specular lighting from this light
  9655. * adds dynamic shadows
  9656. */
  9657. static readonly LIGHTMAP_SPECULAR: number;
  9658. /**
  9659. * material.lightmapTexture as only lighting
  9660. * no light calculation from this light
  9661. * only adds dynamic shadows from this light
  9662. */
  9663. static readonly LIGHTMAP_SHADOWSONLY: number;
  9664. /**
  9665. * Each light type uses the default quantity according to its type:
  9666. * point/spot lights use luminous intensity
  9667. * directional lights use illuminance
  9668. */
  9669. static readonly INTENSITYMODE_AUTOMATIC: number;
  9670. /**
  9671. * lumen (lm)
  9672. */
  9673. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9674. /**
  9675. * candela (lm/sr)
  9676. */
  9677. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9678. /**
  9679. * lux (lm/m^2)
  9680. */
  9681. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9682. /**
  9683. * nit (cd/m^2)
  9684. */
  9685. static readonly INTENSITYMODE_LUMINANCE: number;
  9686. /**
  9687. * Light type const id of the point light.
  9688. */
  9689. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9690. /**
  9691. * Light type const id of the directional light.
  9692. */
  9693. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9694. /**
  9695. * Light type const id of the spot light.
  9696. */
  9697. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9698. /**
  9699. * Light type const id of the hemispheric light.
  9700. */
  9701. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9702. /**
  9703. * Diffuse gives the basic color to an object.
  9704. */
  9705. diffuse: Color3;
  9706. /**
  9707. * Specular produces a highlight color on an object.
  9708. * Note: This is note affecting PBR materials.
  9709. */
  9710. specular: Color3;
  9711. /**
  9712. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9713. * falling off base on range or angle.
  9714. * This can be set to any values in Light.FALLOFF_x.
  9715. *
  9716. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9717. * other types of materials.
  9718. */
  9719. falloffType: number;
  9720. /**
  9721. * Strength of the light.
  9722. * Note: By default it is define in the framework own unit.
  9723. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9724. */
  9725. intensity: number;
  9726. private _range;
  9727. protected _inverseSquaredRange: number;
  9728. /**
  9729. * Defines how far from the source the light is impacting in scene units.
  9730. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9731. */
  9732. /**
  9733. * Defines how far from the source the light is impacting in scene units.
  9734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9735. */
  9736. range: number;
  9737. /**
  9738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9739. * of light.
  9740. */
  9741. private _photometricScale;
  9742. private _intensityMode;
  9743. /**
  9744. * Gets the photometric scale used to interpret the intensity.
  9745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9746. */
  9747. /**
  9748. * Sets the photometric scale used to interpret the intensity.
  9749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9750. */
  9751. intensityMode: number;
  9752. private _radius;
  9753. /**
  9754. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9755. */
  9756. /**
  9757. * sets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. radius: number;
  9760. private _renderPriority;
  9761. /**
  9762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9763. * exceeding the number allowed of the materials.
  9764. */
  9765. renderPriority: number;
  9766. private _shadowEnabled;
  9767. /**
  9768. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9769. * the current shadow generator.
  9770. */
  9771. /**
  9772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9773. * the current shadow generator.
  9774. */
  9775. shadowEnabled: boolean;
  9776. private _includedOnlyMeshes;
  9777. /**
  9778. * Gets the only meshes impacted by this light.
  9779. */
  9780. /**
  9781. * Sets the only meshes impacted by this light.
  9782. */
  9783. includedOnlyMeshes: AbstractMesh[];
  9784. private _excludedMeshes;
  9785. /**
  9786. * Gets the meshes not impacted by this light.
  9787. */
  9788. /**
  9789. * Sets the meshes not impacted by this light.
  9790. */
  9791. excludedMeshes: AbstractMesh[];
  9792. private _excludeWithLayerMask;
  9793. /**
  9794. * Gets the layer id use to find what meshes are not impacted by the light.
  9795. * Inactive if 0
  9796. */
  9797. /**
  9798. * Sets the layer id use to find what meshes are not impacted by the light.
  9799. * Inactive if 0
  9800. */
  9801. excludeWithLayerMask: number;
  9802. private _includeOnlyWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. includeOnlyWithLayerMask: number;
  9812. private _lightmapMode;
  9813. /**
  9814. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9815. */
  9816. /**
  9817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. lightmapMode: number;
  9820. /**
  9821. * Shadow generator associted to the light.
  9822. * @hidden Internal use only.
  9823. */
  9824. _shadowGenerator: Nullable<IShadowGenerator>;
  9825. /**
  9826. * @hidden Internal use only.
  9827. */
  9828. _excludedMeshesIds: string[];
  9829. /**
  9830. * @hidden Internal use only.
  9831. */
  9832. _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */
  9837. _uniformBuffer: UniformBuffer;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Returns the string "Light".
  9855. * @returns the class name
  9856. */
  9857. getClassName(): string;
  9858. /** @hidden */
  9859. readonly _isLight: boolean;
  9860. /**
  9861. * Converts the light information to a readable string for debug purpose.
  9862. * @param fullDetails Supports for multiple levels of logging within scene loading
  9863. * @returns the human readable light info
  9864. */
  9865. toString(fullDetails?: boolean): string;
  9866. /** @hidden */
  9867. protected _syncParentEnabledState(): void;
  9868. /**
  9869. * Set the enabled state of this node.
  9870. * @param value - the new enabled state
  9871. */
  9872. setEnabled(value: boolean): void;
  9873. /**
  9874. * Returns the Light associated shadow generator if any.
  9875. * @return the associated shadow generator.
  9876. */
  9877. getShadowGenerator(): Nullable<IShadowGenerator>;
  9878. /**
  9879. * Returns a Vector3, the absolute light position in the World.
  9880. * @returns the world space position of the light
  9881. */
  9882. getAbsolutePosition(): Vector3;
  9883. /**
  9884. * Specifies if the light will affect the passed mesh.
  9885. * @param mesh The mesh to test against the light
  9886. * @return true the mesh is affected otherwise, false.
  9887. */
  9888. canAffectMesh(mesh: AbstractMesh): boolean;
  9889. /**
  9890. * Sort function to order lights for rendering.
  9891. * @param a First Light object to compare to second.
  9892. * @param b Second Light object to compare first.
  9893. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9894. */
  9895. static CompareLightsPriority(a: Light, b: Light): number;
  9896. /**
  9897. * Releases resources associated with this node.
  9898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9900. */
  9901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9902. /**
  9903. * Returns the light type ID (integer).
  9904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9905. */
  9906. getTypeID(): number;
  9907. /**
  9908. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9909. * @returns the scaled intensity in intensity mode unit
  9910. */
  9911. getScaledIntensity(): number;
  9912. /**
  9913. * Returns a new Light object, named "name", from the current one.
  9914. * @param name The name of the cloned light
  9915. * @returns the new created light
  9916. */
  9917. clone(name: string): Nullable<Light>;
  9918. /**
  9919. * Serializes the current light into a Serialization object.
  9920. * @returns the serialized object.
  9921. */
  9922. serialize(): any;
  9923. /**
  9924. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9925. * This new light is named "name" and added to the passed scene.
  9926. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9927. * @param name The friendly name of the light
  9928. * @param scene The scene the new light will belong to
  9929. * @returns the constructor function
  9930. */
  9931. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9932. /**
  9933. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9934. * @param parsedLight The JSON representation of the light
  9935. * @param scene The scene to create the parsed light in
  9936. * @returns the created light after parsing
  9937. */
  9938. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9939. private _hookArrayForExcluded;
  9940. private _hookArrayForIncludedOnly;
  9941. private _resyncMeshes;
  9942. /**
  9943. * Forces the meshes to update their light related information in their rendering used effects
  9944. * @hidden Internal Use Only
  9945. */
  9946. _markMeshesAsLightDirty(): void;
  9947. /**
  9948. * Recomputes the cached photometric scale if needed.
  9949. */
  9950. private _computePhotometricScale;
  9951. /**
  9952. * Returns the Photometric Scale according to the light type and intensity mode.
  9953. */
  9954. private _getPhotometricScale;
  9955. /**
  9956. * Reorder the light in the scene according to their defined priority.
  9957. * @hidden Internal Use Only
  9958. */
  9959. _reorderLightsInScene(): void;
  9960. /**
  9961. * Prepares the list of defines specific to the light type.
  9962. * @param defines the list of defines
  9963. * @param lightIndex defines the index of the light for the effect
  9964. */
  9965. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Interface used to define Action
  9971. */
  9972. export interface IAction {
  9973. /**
  9974. * Trigger for the action
  9975. */
  9976. trigger: number;
  9977. /** Options of the trigger */
  9978. triggerOptions: any;
  9979. /**
  9980. * Gets the trigger parameters
  9981. * @returns the trigger parameters
  9982. */
  9983. getTriggerParameter(): any;
  9984. /**
  9985. * Internal only - executes current action event
  9986. * @hidden
  9987. */
  9988. _executeCurrent(evt?: ActionEvent): void;
  9989. /**
  9990. * Serialize placeholder for child classes
  9991. * @param parent of child
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. /**
  9996. * Internal only
  9997. * @hidden
  9998. */
  9999. _prepare(): void;
  10000. /**
  10001. * Internal only - manager for action
  10002. * @hidden
  10003. */
  10004. _actionManager: AbstractActionManager;
  10005. /**
  10006. * Adds action to chain of actions, may be a DoNothingAction
  10007. * @param action defines the next action to execute
  10008. * @returns The action passed in
  10009. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10010. */
  10011. then(action: IAction): IAction;
  10012. }
  10013. /**
  10014. * The action to be carried out following a trigger
  10015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10016. */
  10017. export class Action implements IAction {
  10018. /** the trigger, with or without parameters, for the action */
  10019. triggerOptions: any;
  10020. /**
  10021. * Trigger for the action
  10022. */
  10023. trigger: number;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */
  10049. _prepare(): void;
  10050. /**
  10051. * Gets the trigger parameters
  10052. * @returns the trigger parameters
  10053. */
  10054. getTriggerParameter(): any;
  10055. /**
  10056. * Internal only - executes current action event
  10057. * @hidden
  10058. */
  10059. _executeCurrent(evt?: ActionEvent): void;
  10060. /**
  10061. * Execute placeholder for child classes
  10062. * @param evt optional action event
  10063. */
  10064. execute(evt?: ActionEvent): void;
  10065. /**
  10066. * Skips to next active action
  10067. */
  10068. skipToNextActiveAction(): void;
  10069. /**
  10070. * Adds action to chain of actions, may be a DoNothingAction
  10071. * @param action defines the next action to execute
  10072. * @returns The action passed in
  10073. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10074. */
  10075. then(action: Action): Action;
  10076. /**
  10077. * Internal only
  10078. * @hidden
  10079. */
  10080. _getProperty(propertyPath: string): string;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getEffectiveTarget(target: any, propertyPath: string): any;
  10086. /**
  10087. * Serialize placeholder for child classes
  10088. * @param parent of child
  10089. * @returns the serialized object
  10090. */
  10091. serialize(parent: any): any;
  10092. /**
  10093. * Internal only called by serialize
  10094. * @hidden
  10095. */
  10096. protected _serialize(serializedAction: any, parent?: any): any;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */
  10101. static _SerializeValueAsString: (value: any) => string;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _GetTargetProperty: (target: Node | Scene) => {
  10107. name: string;
  10108. targetType: string;
  10109. value: string;
  10110. };
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. /**
  10115. * A Condition applied to an Action
  10116. */
  10117. export class Condition {
  10118. /**
  10119. * Internal only - manager for action
  10120. * @hidden
  10121. */
  10122. _actionManager: ActionManager;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _evaluationId: number;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _currentResult: boolean;
  10133. /**
  10134. * Creates a new Condition
  10135. * @param actionManager the manager of the action the condition is applied to
  10136. */
  10137. constructor(actionManager: ActionManager);
  10138. /**
  10139. * Check if the current condition is valid
  10140. * @returns a boolean
  10141. */
  10142. isValid(): boolean;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. _getProperty(propertyPath: string): string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getEffectiveTarget(target: any, propertyPath: string): any;
  10153. /**
  10154. * Serialize placeholder for child classes
  10155. * @returns the serialized object
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. protected _serialize(serializedCondition: any): any;
  10163. }
  10164. /**
  10165. * Defines specific conditional operators as extensions of Condition
  10166. */
  10167. export class ValueCondition extends Condition {
  10168. /** path to specify the property of the target the conditional operator uses */
  10169. propertyPath: string;
  10170. /** the value compared by the conditional operator against the current value of the property */
  10171. value: any;
  10172. /** the conditional operator, default ValueCondition.IsEqual */
  10173. operator: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. private static _IsEqual;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsDifferent;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsGreater;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsLesser;
  10194. /**
  10195. * returns the number for IsEqual
  10196. */
  10197. static readonly IsEqual: number;
  10198. /**
  10199. * Returns the number for IsDifferent
  10200. */
  10201. static readonly IsDifferent: number;
  10202. /**
  10203. * Returns the number for IsGreater
  10204. */
  10205. static readonly IsGreater: number;
  10206. /**
  10207. * Returns the number for IsLesser
  10208. */
  10209. static readonly IsLesser: number;
  10210. /**
  10211. * Internal only The action manager for the condition
  10212. * @hidden
  10213. */
  10214. _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _effectiveTarget;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _property;
  10230. /**
  10231. * Creates a new ValueCondition
  10232. * @param actionManager manager for the action the condition applies to
  10233. * @param target for the action
  10234. * @param propertyPath path to specify the property of the target the conditional operator uses
  10235. * @param value the value compared by the conditional operator against the current value of the property
  10236. * @param operator the conditional operator, default ValueCondition.IsEqual
  10237. */
  10238. constructor(actionManager: ActionManager, target: any,
  10239. /** path to specify the property of the target the conditional operator uses */
  10240. propertyPath: string,
  10241. /** the value compared by the conditional operator against the current value of the property */
  10242. value: any,
  10243. /** the conditional operator, default ValueCondition.IsEqual */
  10244. operator?: number);
  10245. /**
  10246. * Compares the given value with the property value for the specified conditional operator
  10247. * @returns the result of the comparison
  10248. */
  10249. isValid(): boolean;
  10250. /**
  10251. * Serialize the ValueCondition into a JSON compatible object
  10252. * @returns serialization object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Gets the name of the conditional operator for the ValueCondition
  10257. * @param operator the conditional operator
  10258. * @returns the name
  10259. */
  10260. static GetOperatorName(operator: number): string;
  10261. }
  10262. /**
  10263. * Defines a predicate condition as an extension of Condition
  10264. */
  10265. export class PredicateCondition extends Condition {
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Creates a new PredicateCondition
  10275. * @param actionManager manager for the action the condition applies to
  10276. * @param predicate defines the predicate function used to validate the condition
  10277. */
  10278. constructor(actionManager: ActionManager,
  10279. /** defines the predicate function used to validate the condition */
  10280. predicate: () => boolean);
  10281. /**
  10282. * @returns the validity of the predicate condition
  10283. */
  10284. isValid(): boolean;
  10285. }
  10286. /**
  10287. * Defines a state condition as an extension of Condition
  10288. */
  10289. export class StateCondition extends Condition {
  10290. /** Value to compare with target state */
  10291. value: string;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Creates a new StateCondition
  10304. * @param actionManager manager for the action the condition applies to
  10305. * @param target of the condition
  10306. * @param value to compare with target state
  10307. */
  10308. constructor(actionManager: ActionManager, target: any,
  10309. /** Value to compare with target state */
  10310. value: string);
  10311. /**
  10312. * Gets a boolean indicating if the current condition is met
  10313. * @returns the validity of the state
  10314. */
  10315. isValid(): boolean;
  10316. /**
  10317. * Serialize the StateCondition into a JSON compatible object
  10318. * @returns serialization object
  10319. */
  10320. serialize(): any;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This defines an action responsible to toggle a boolean once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SwitchBooleanAction extends Action {
  10329. /**
  10330. * The path to the boolean property in the target object
  10331. */
  10332. propertyPath: string;
  10333. private _target;
  10334. private _effectiveTarget;
  10335. private _property;
  10336. /**
  10337. * Instantiate the action
  10338. * @param triggerOptions defines the trigger options
  10339. * @param target defines the object containing the boolean
  10340. * @param propertyPath defines the path to the boolean property in the target object
  10341. * @param condition defines the trigger related conditions
  10342. */
  10343. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10344. /** @hidden */
  10345. _prepare(): void;
  10346. /**
  10347. * Execute the action toggle the boolean value.
  10348. */
  10349. execute(): void;
  10350. /**
  10351. * Serializes the actions and its related information.
  10352. * @param parent defines the object to serialize in
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. }
  10357. /**
  10358. * This defines an action responsible to set a the state field of the target
  10359. * to a desired value once triggered.
  10360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10361. */
  10362. export class SetStateAction extends Action {
  10363. /**
  10364. * The value to store in the state field.
  10365. */
  10366. value: string;
  10367. private _target;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the state property
  10372. * @param value defines the value to store in the state field
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10376. /**
  10377. * Execute the action and store the value on the target state property.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to set a property of the target
  10389. * to a desired value once triggered.
  10390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10391. */
  10392. export class SetValueAction extends Action {
  10393. /**
  10394. * The path of the property to set in the target.
  10395. */
  10396. propertyPath: string;
  10397. /**
  10398. * The value to set in the property
  10399. */
  10400. value: any;
  10401. private _target;
  10402. private _effectiveTarget;
  10403. private _property;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the property
  10408. * @param propertyPath defines the path of the property to set in the target
  10409. * @param value defines the value to set in the property
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10413. /** @hidden */
  10414. _prepare(): void;
  10415. /**
  10416. * Execute the action and set the targetted property to the desired value.
  10417. */
  10418. execute(): void;
  10419. /**
  10420. * Serializes the actions and its related information.
  10421. * @param parent defines the object to serialize in
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. }
  10426. /**
  10427. * This defines an action responsible to increment the target value
  10428. * to a desired value once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class IncrementValueAction extends Action {
  10432. /**
  10433. * The path of the property to increment in the target.
  10434. */
  10435. propertyPath: string;
  10436. /**
  10437. * The value we should increment the property by.
  10438. */
  10439. value: any;
  10440. private _target;
  10441. private _effectiveTarget;
  10442. private _property;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the property
  10447. * @param propertyPath defines the path of the property to increment in the target
  10448. * @param value defines the value value we should increment the property by
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action and increment the target of the value amount.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to start an animation once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class PlayAnimationAction extends Action {
  10470. /**
  10471. * Where the animation should start (animation frame)
  10472. */
  10473. from: number;
  10474. /**
  10475. * Where the animation should stop (animation frame)
  10476. */
  10477. to: number;
  10478. /**
  10479. * Define if the animation should loop or stop after the first play.
  10480. */
  10481. loop?: boolean;
  10482. private _target;
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param target defines the target animation or animation name
  10487. * @param from defines from where the animation should start (animation frame)
  10488. * @param end defines where the animation should stop (animation frame)
  10489. * @param loop defines if the animation should loop or stop after the first play
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */
  10520. _prepare(): void;
  10521. /**
  10522. * Execute the action and stop the animation.
  10523. */
  10524. execute(): void;
  10525. /**
  10526. * Serializes the actions and its related information.
  10527. * @param parent defines the object to serialize in
  10528. * @returns the serialized object
  10529. */
  10530. serialize(parent: any): any;
  10531. }
  10532. /**
  10533. * This defines an action responsible that does nothing once triggered.
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10535. */
  10536. export class DoNothingAction extends Action {
  10537. /**
  10538. * Instantiate the action
  10539. * @param triggerOptions defines the trigger options
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions?: any, condition?: Condition);
  10543. /**
  10544. * Execute the action and do nothing.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to trigger several actions once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class CombineAction extends Action {
  10559. /**
  10560. * The list of aggregated animations to run.
  10561. */
  10562. children: Action[];
  10563. /**
  10564. * Instantiate the action
  10565. * @param triggerOptions defines the trigger options
  10566. * @param children defines the list of aggregated animations to run
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and executes all the aggregated actions.
  10574. */
  10575. execute(evt: ActionEvent): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to run code (external event) once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class ExecuteCodeAction extends Action {
  10588. /**
  10589. * The callback function to run.
  10590. */
  10591. func: (evt: ActionEvent) => void;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param func defines the callback function to run
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10599. /**
  10600. * Execute the action and run the attached code.
  10601. */
  10602. execute(evt: ActionEvent): void;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set the parent property of the target once triggered.
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10607. */
  10608. export class SetParentAction extends Action {
  10609. private _parent;
  10610. private _target;
  10611. /**
  10612. * Instantiate the action
  10613. * @param triggerOptions defines the trigger options
  10614. * @param target defines the target containing the parent property
  10615. * @param parent defines from where the animation should start (animation frame)
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the parent property.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10636. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class ActionManager extends AbstractActionManager {
  10640. /**
  10641. * Nothing
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10643. */
  10644. static readonly NothingTrigger: number;
  10645. /**
  10646. * On pick
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly OnPickTrigger: number;
  10650. /**
  10651. * On left pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnLeftPickTrigger: number;
  10655. /**
  10656. * On right pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnRightPickTrigger: number;
  10660. /**
  10661. * On center pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnCenterPickTrigger: number;
  10665. /**
  10666. * On pick down
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnPickDownTrigger: number;
  10670. /**
  10671. * On double pick
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnDoublePickTrigger: number;
  10675. /**
  10676. * On pick up
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickUpTrigger: number;
  10680. /**
  10681. * On pick out.
  10682. * This trigger will only be raised if you also declared a OnPickDown
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickOutTrigger: number;
  10686. /**
  10687. * On long press
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLongPressTrigger: number;
  10691. /**
  10692. * On pointer over
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPointerOverTrigger: number;
  10696. /**
  10697. * On pointer out
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOutTrigger: number;
  10701. /**
  10702. * On every frame
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnEveryFrameTrigger: number;
  10706. /**
  10707. * On intersection enter
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnIntersectionEnterTrigger: number;
  10711. /**
  10712. * On intersection exit
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionExitTrigger: number;
  10716. /**
  10717. * On key down
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnKeyDownTrigger: number;
  10721. /**
  10722. * On key up
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyUpTrigger: number;
  10726. private _scene;
  10727. /**
  10728. * Creates a new action manager
  10729. * @param scene defines the hosting scene
  10730. */
  10731. constructor(scene: Scene);
  10732. /**
  10733. * Releases all associated resources
  10734. */
  10735. dispose(): void;
  10736. /**
  10737. * Gets hosting scene
  10738. * @returns the hosting scene
  10739. */
  10740. getScene(): Scene;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Does this action manager has pointer triggers
  10764. */
  10765. readonly hasPointerTriggers: boolean;
  10766. /**
  10767. * Does this action manager has pick triggers
  10768. */
  10769. readonly hasPickTriggers: boolean;
  10770. /**
  10771. * Registers an action to this action manager
  10772. * @param action defines the action to be registered
  10773. * @return the action amended (prepared) after registration
  10774. */
  10775. registerAction(action: IAction): Nullable<IAction>;
  10776. /**
  10777. * Unregisters an action to this action manager
  10778. * @param action defines the action to be unregistered
  10779. * @return a boolean indicating whether the action has been unregistered
  10780. */
  10781. unregisterAction(action: IAction): Boolean;
  10782. /**
  10783. * Process a specific trigger
  10784. * @param trigger defines the trigger to process
  10785. * @param evt defines the event details to be processed
  10786. */
  10787. processTrigger(trigger: number, evt?: IActionEvent): void;
  10788. /** @hidden */
  10789. _getEffectiveTarget(target: any, propertyPath: string): any;
  10790. /** @hidden */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Serialize this manager to a JSON object
  10794. * @param name defines the property name to store this manager
  10795. * @returns a JSON representation of this manager
  10796. */
  10797. serialize(name: string): any;
  10798. /**
  10799. * Creates a new ActionManager from a JSON data
  10800. * @param parsedActions defines the JSON data to read from
  10801. * @param object defines the hosting mesh
  10802. * @param scene defines the hosting scene
  10803. */
  10804. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10805. /**
  10806. * Get a trigger name by index
  10807. * @param trigger defines the trigger index
  10808. * @returns a trigger name
  10809. */
  10810. static GetTriggerName(trigger: number): string;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * Class representing a ray with position and direction
  10816. */
  10817. export class Ray {
  10818. /** origin point */
  10819. origin: Vector3;
  10820. /** direction */
  10821. direction: Vector3;
  10822. /** length of the ray */
  10823. length: number;
  10824. private static readonly TmpVector3;
  10825. private _tmpRay;
  10826. /**
  10827. * Creates a new ray
  10828. * @param origin origin point
  10829. * @param direction direction
  10830. * @param length length of the ray
  10831. */
  10832. constructor(
  10833. /** origin point */
  10834. origin: Vector3,
  10835. /** direction */
  10836. direction: Vector3,
  10837. /** length of the ray */
  10838. length?: number);
  10839. /**
  10840. * Checks if the ray intersects a box
  10841. * @param minimum bound of the box
  10842. * @param maximum bound of the box
  10843. * @param intersectionTreshold extra extend to be added to the box in all direction
  10844. * @returns if the box was hit
  10845. */
  10846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10847. /**
  10848. * Checks if the ray intersects a box
  10849. * @param box the bounding box to check
  10850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10851. * @returns if the box was hit
  10852. */
  10853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10854. /**
  10855. * If the ray hits a sphere
  10856. * @param sphere the bounding sphere to check
  10857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10858. * @returns true if it hits the sphere
  10859. */
  10860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10861. /**
  10862. * If the ray hits a triange
  10863. * @param vertex0 triangle vertex
  10864. * @param vertex1 triangle vertex
  10865. * @param vertex2 triangle vertex
  10866. * @returns intersection information if hit
  10867. */
  10868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10869. /**
  10870. * Checks if ray intersects a plane
  10871. * @param plane the plane to check
  10872. * @returns the distance away it was hit
  10873. */
  10874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10875. /**
  10876. * Calculate the intercept of a ray on a given axis
  10877. * @param axis to check 'x' | 'y' | 'z'
  10878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10880. */
  10881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10882. /**
  10883. * Checks if ray intersects a mesh
  10884. * @param mesh the mesh to check
  10885. * @param fastCheck if only the bounding box should checked
  10886. * @returns picking info of the intersecton
  10887. */
  10888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10889. /**
  10890. * Checks if ray intersects a mesh
  10891. * @param meshes the meshes to check
  10892. * @param fastCheck if only the bounding box should checked
  10893. * @param results array to store result in
  10894. * @returns Array of picking infos
  10895. */
  10896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10897. private _comparePickingInfo;
  10898. private static smallnum;
  10899. private static rayl;
  10900. /**
  10901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10902. * @param sega the first point of the segment to test the intersection against
  10903. * @param segb the second point of the segment to test the intersection against
  10904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10906. */
  10907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10908. /**
  10909. * Update the ray from viewport position
  10910. * @param x position
  10911. * @param y y position
  10912. * @param viewportWidth viewport width
  10913. * @param viewportHeight viewport height
  10914. * @param world world matrix
  10915. * @param view view matrix
  10916. * @param projection projection matrix
  10917. * @returns this ray updated
  10918. */
  10919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10920. /**
  10921. * Creates a ray with origin and direction of 0,0,0
  10922. * @returns the new ray
  10923. */
  10924. static Zero(): Ray;
  10925. /**
  10926. * Creates a new ray from screen space and viewport
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns new ray
  10935. */
  10936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * 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
  10939. * transformed to the given world matrix.
  10940. * @param origin The origin point
  10941. * @param end The end point
  10942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10943. * @returns the new ray
  10944. */
  10945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Transforms a ray by a matrix
  10948. * @param ray ray to transform
  10949. * @param matrix matrix to apply
  10950. * @returns the resulting new ray
  10951. */
  10952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10953. /**
  10954. * Transforms a ray by a matrix
  10955. * @param ray ray to transform
  10956. * @param matrix matrix to apply
  10957. * @param result ray to store result in
  10958. */
  10959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10960. /**
  10961. * Unproject a ray from screen space to object space
  10962. * @param sourceX defines the screen space x coordinate to use
  10963. * @param sourceY defines the screen space y coordinate to use
  10964. * @param viewportWidth defines the current width of the viewport
  10965. * @param viewportHeight defines the current height of the viewport
  10966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10967. * @param view defines the view matrix to use
  10968. * @param projection defines the projection matrix to use
  10969. */
  10970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10971. }
  10972. /**
  10973. * Type used to define predicate used to select faces when a mesh intersection is detected
  10974. */
  10975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10976. interface Scene {
  10977. /** @hidden */
  10978. _tempPickingRay: Nullable<Ray>;
  10979. /** @hidden */
  10980. _cachedRayForTransform: Ray;
  10981. /** @hidden */
  10982. _pickWithRayInverseMatrix: Matrix;
  10983. /** @hidden */
  10984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10985. /** @hidden */
  10986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Groups all the scene component constants in one place to ease maintenance.
  10992. * @hidden
  10993. */
  10994. export class SceneComponentConstants {
  10995. static readonly NAME_EFFECTLAYER: string;
  10996. static readonly NAME_LAYER: string;
  10997. static readonly NAME_LENSFLARESYSTEM: string;
  10998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10999. static readonly NAME_PARTICLESYSTEM: string;
  11000. static readonly NAME_GAMEPAD: string;
  11001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11003. static readonly NAME_DEPTHRENDERER: string;
  11004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11005. static readonly NAME_SPRITE: string;
  11006. static readonly NAME_OUTLINERENDERER: string;
  11007. static readonly NAME_PROCEDURALTEXTURE: string;
  11008. static readonly NAME_SHADOWGENERATOR: string;
  11009. static readonly NAME_OCTREE: string;
  11010. static readonly NAME_PHYSICSENGINE: string;
  11011. static readonly NAME_AUDIO: string;
  11012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11032. static readonly STEP_AFTERRENDER_AUDIO: number;
  11033. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11035. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11038. static readonly STEP_POINTERMOVE_SPRITE: number;
  11039. static readonly STEP_POINTERDOWN_SPRITE: number;
  11040. static readonly STEP_POINTERUP_SPRITE: number;
  11041. }
  11042. /**
  11043. * This represents a scene component.
  11044. *
  11045. * This is used to decouple the dependency the scene is having on the different workloads like
  11046. * layers, post processes...
  11047. */
  11048. export interface ISceneComponent {
  11049. /**
  11050. * The name of the component. Each component must have a unique name.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The scene the component belongs to.
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Register the component to one instance of a scene.
  11059. */
  11060. register(): void;
  11061. /**
  11062. * Rebuilds the elements related to this component in case of
  11063. * context lost for instance.
  11064. */
  11065. rebuild(): void;
  11066. /**
  11067. * Disposes the component and the associated ressources.
  11068. */
  11069. dispose(): void;
  11070. }
  11071. /**
  11072. * This represents a SERIALIZABLE scene component.
  11073. *
  11074. * This extends Scene Component to add Serialization methods on top.
  11075. */
  11076. export interface ISceneSerializableComponent extends ISceneComponent {
  11077. /**
  11078. * Adds all the elements from the container to the scene
  11079. * @param container the container holding the elements
  11080. */
  11081. addFromContainer(container: AbstractScene): void;
  11082. /**
  11083. * Removes all the elements in the container from the scene
  11084. * @param container contains the elements to remove
  11085. * @param dispose if the removed element should be disposed (default: false)
  11086. */
  11087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11088. /**
  11089. * Serializes the component data to the specified json object
  11090. * @param serializationObject The object to serialize to
  11091. */
  11092. serialize(serializationObject: any): void;
  11093. }
  11094. /**
  11095. * Strong typing of a Mesh related stage step action
  11096. */
  11097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11098. /**
  11099. * Strong typing of a Evaluate Sub Mesh related stage step action
  11100. */
  11101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11102. /**
  11103. * Strong typing of a Active Mesh related stage step action
  11104. */
  11105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11106. /**
  11107. * Strong typing of a Camera related stage step action
  11108. */
  11109. export type CameraStageAction = (camera: Camera) => void;
  11110. /**
  11111. * Strong typing of a Camera Frame buffer related stage step action
  11112. */
  11113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11114. /**
  11115. * Strong typing of a Render Target related stage step action
  11116. */
  11117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11118. /**
  11119. * Strong typing of a RenderingGroup related stage step action
  11120. */
  11121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11122. /**
  11123. * Strong typing of a Mesh Render related stage step action
  11124. */
  11125. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11126. /**
  11127. * Strong typing of a simple stage step action
  11128. */
  11129. export type SimpleStageAction = () => void;
  11130. /**
  11131. * Strong typing of a render target action.
  11132. */
  11133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11134. /**
  11135. * Strong typing of a pointer move action.
  11136. */
  11137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11138. /**
  11139. * Strong typing of a pointer up/down action.
  11140. */
  11141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11142. /**
  11143. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11144. * @hidden
  11145. */
  11146. export class Stage<T extends Function> extends Array<{
  11147. index: number;
  11148. component: ISceneComponent;
  11149. action: T;
  11150. }> {
  11151. /**
  11152. * Hide ctor from the rest of the world.
  11153. * @param items The items to add.
  11154. */
  11155. private constructor();
  11156. /**
  11157. * Creates a new Stage.
  11158. * @returns A new instance of a Stage
  11159. */
  11160. static Create<T extends Function>(): Stage<T>;
  11161. /**
  11162. * Registers a step in an ordered way in the targeted stage.
  11163. * @param index Defines the position to register the step in
  11164. * @param component Defines the component attached to the step
  11165. * @param action Defines the action to launch during the step
  11166. */
  11167. registerStep(index: number, component: ISceneComponent, action: T): void;
  11168. /**
  11169. * Clears all the steps from the stage.
  11170. */
  11171. clear(): void;
  11172. }
  11173. }
  11174. declare module BABYLON {
  11175. interface Scene {
  11176. /** @hidden */
  11177. _pointerOverSprite: Nullable<Sprite>;
  11178. /** @hidden */
  11179. _pickedDownSprite: Nullable<Sprite>;
  11180. /** @hidden */
  11181. _tempSpritePickingRay: Nullable<Ray>;
  11182. /**
  11183. * All of the sprite managers added to this scene
  11184. * @see http://doc.babylonjs.com/babylon101/sprites
  11185. */
  11186. spriteManagers: Array<ISpriteManager>;
  11187. /**
  11188. * An event triggered when sprites rendering is about to start
  11189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11190. */
  11191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11192. /**
  11193. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  11197. /** @hidden */
  11198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11199. /** Launch a ray to try to pick a sprite in the scene
  11200. * @param x position on screen
  11201. * @param y position on screen
  11202. * @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
  11203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11205. * @returns a PickingInfo
  11206. */
  11207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11208. /** Use the given ray to pick a sprite in the scene
  11209. * @param ray The ray (in world space) to use to pick meshes
  11210. * @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
  11211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11213. * @returns a PickingInfo
  11214. */
  11215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /**
  11217. * Force the sprite under the pointer
  11218. * @param sprite defines the sprite to use
  11219. */
  11220. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11221. /**
  11222. * Gets the sprite under the pointer
  11223. * @returns a Sprite or null if no sprite is under the pointer
  11224. */
  11225. getPointerOverSprite(): Nullable<Sprite>;
  11226. }
  11227. /**
  11228. * Defines the sprite scene component responsible to manage sprites
  11229. * in a given scene.
  11230. */
  11231. export class SpriteSceneComponent implements ISceneComponent {
  11232. /**
  11233. * The component name helpfull to identify the component in the list of scene components.
  11234. */
  11235. readonly name: string;
  11236. /**
  11237. * The scene the component belongs to.
  11238. */
  11239. scene: Scene;
  11240. /** @hidden */
  11241. private _spritePredicate;
  11242. /**
  11243. * Creates a new instance of the component for the given scene
  11244. * @param scene Defines the scene to register the component in
  11245. */
  11246. constructor(scene: Scene);
  11247. /**
  11248. * Registers the component in a given scene
  11249. */
  11250. register(): void;
  11251. /**
  11252. * Rebuilds the elements related to this component in case of
  11253. * context lost for instance.
  11254. */
  11255. rebuild(): void;
  11256. /**
  11257. * Disposes the component and the associated ressources.
  11258. */
  11259. dispose(): void;
  11260. private _pickSpriteButKeepRay;
  11261. private _pointerMove;
  11262. private _pointerDown;
  11263. private _pointerUp;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogFragmentDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var fogFragment: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /** @hidden */
  11282. export var spritesPixelShader: {
  11283. name: string;
  11284. shader: string;
  11285. };
  11286. }
  11287. declare module BABYLON {
  11288. /** @hidden */
  11289. export var fogVertexDeclaration: {
  11290. name: string;
  11291. shader: string;
  11292. };
  11293. }
  11294. declare module BABYLON {
  11295. /** @hidden */
  11296. export var spritesVertexShader: {
  11297. name: string;
  11298. shader: string;
  11299. };
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11304. */
  11305. export interface ISpriteManager extends IDisposable {
  11306. /**
  11307. * Restricts the camera to viewing objects with the same layerMask.
  11308. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11309. */
  11310. layerMask: number;
  11311. /**
  11312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11313. */
  11314. isPickable: boolean;
  11315. /**
  11316. * Specifies the rendering group id for this mesh (0 by default)
  11317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11318. */
  11319. renderingGroupId: number;
  11320. /**
  11321. * Defines the list of sprites managed by the manager.
  11322. */
  11323. sprites: Array<Sprite>;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Renders the list of sprites on screen.
  11335. */
  11336. render(): void;
  11337. }
  11338. /**
  11339. * Class used to manage multiple sprites on the same spritesheet
  11340. * @see http://doc.babylonjs.com/babylon101/sprites
  11341. */
  11342. export class SpriteManager implements ISpriteManager {
  11343. /** defines the manager's name */
  11344. name: string;
  11345. /** Gets the list of sprites */
  11346. sprites: Sprite[];
  11347. /** Gets or sets the rendering group id (0 by default) */
  11348. renderingGroupId: number;
  11349. /** Gets or sets camera layer mask */
  11350. layerMask: number;
  11351. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11352. fogEnabled: boolean;
  11353. /** Gets or sets a boolean indicating if the sprites are pickable */
  11354. isPickable: boolean;
  11355. /** Defines the default width of a cell in the spritesheet */
  11356. cellWidth: number;
  11357. /** Defines the default height of a cell in the spritesheet */
  11358. cellHeight: number;
  11359. /**
  11360. * An event triggered when the manager is disposed.
  11361. */
  11362. onDisposeObservable: Observable<SpriteManager>;
  11363. private _onDisposeObserver;
  11364. /**
  11365. * Callback called when the manager is disposed
  11366. */
  11367. onDispose: () => void;
  11368. private _capacity;
  11369. private _spriteTexture;
  11370. private _epsilon;
  11371. private _scene;
  11372. private _vertexData;
  11373. private _buffer;
  11374. private _vertexBuffers;
  11375. private _indexBuffer;
  11376. private _effectBase;
  11377. private _effectFog;
  11378. /**
  11379. * Gets or sets the spritesheet texture
  11380. */
  11381. texture: Texture;
  11382. /**
  11383. * Creates a new sprite manager
  11384. * @param name defines the manager's name
  11385. * @param imgUrl defines the sprite sheet url
  11386. * @param capacity defines the maximum allowed number of sprites
  11387. * @param cellSize defines the size of a sprite cell
  11388. * @param scene defines the hosting scene
  11389. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11390. * @param samplingMode defines the smapling mode to use with spritesheet
  11391. */
  11392. constructor(
  11393. /** defines the manager's name */
  11394. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11395. private _appendSpriteVertex;
  11396. /**
  11397. * Intersects the sprites with a ray
  11398. * @param ray defines the ray to intersect with
  11399. * @param camera defines the current active camera
  11400. * @param predicate defines a predicate used to select candidate sprites
  11401. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11402. * @returns null if no hit or a PickingInfo
  11403. */
  11404. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11405. /**
  11406. * Render all child sprites
  11407. */
  11408. render(): void;
  11409. /**
  11410. * Release associated resources
  11411. */
  11412. dispose(): void;
  11413. }
  11414. }
  11415. declare module BABYLON {
  11416. /**
  11417. * Class used to represent a sprite
  11418. * @see http://doc.babylonjs.com/babylon101/sprites
  11419. */
  11420. export class Sprite {
  11421. /** defines the name */
  11422. name: string;
  11423. /** Gets or sets the current world position */
  11424. position: Vector3;
  11425. /** Gets or sets the main color */
  11426. color: Color4;
  11427. /** Gets or sets the width */
  11428. width: number;
  11429. /** Gets or sets the height */
  11430. height: number;
  11431. /** Gets or sets rotation angle */
  11432. angle: number;
  11433. /** Gets or sets the cell index in the sprite sheet */
  11434. cellIndex: number;
  11435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11436. invertU: number;
  11437. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11438. invertV: number;
  11439. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11440. disposeWhenFinishedAnimating: boolean;
  11441. /** Gets the list of attached animations */
  11442. animations: Animation[];
  11443. /** Gets or sets a boolean indicating if the sprite can be picked */
  11444. isPickable: boolean;
  11445. /**
  11446. * Gets or sets the associated action manager
  11447. */
  11448. actionManager: Nullable<ActionManager>;
  11449. private _animationStarted;
  11450. private _loopAnimation;
  11451. private _fromIndex;
  11452. private _toIndex;
  11453. private _delay;
  11454. private _direction;
  11455. private _manager;
  11456. private _time;
  11457. private _onAnimationEnd;
  11458. /**
  11459. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11460. */
  11461. isVisible: boolean;
  11462. /**
  11463. * Gets or sets the sprite size
  11464. */
  11465. size: number;
  11466. /**
  11467. * Creates a new Sprite
  11468. * @param name defines the name
  11469. * @param manager defines the manager
  11470. */
  11471. constructor(
  11472. /** defines the name */
  11473. name: string, manager: ISpriteManager);
  11474. /**
  11475. * Starts an animation
  11476. * @param from defines the initial key
  11477. * @param to defines the end key
  11478. * @param loop defines if the animation must loop
  11479. * @param delay defines the start delay (in ms)
  11480. * @param onAnimationEnd defines a callback to call when animation ends
  11481. */
  11482. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11483. /** Stops current animation (if any) */
  11484. stopAnimation(): void;
  11485. /** @hidden */
  11486. _animate(deltaTime: number): void;
  11487. /** Release associated resources */
  11488. dispose(): void;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. /**
  11493. * Information about the result of picking within a scene
  11494. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11495. */
  11496. export class PickingInfo {
  11497. /** @hidden */
  11498. _pickingUnavailable: boolean;
  11499. /**
  11500. * If the pick collided with an object
  11501. */
  11502. hit: boolean;
  11503. /**
  11504. * Distance away where the pick collided
  11505. */
  11506. distance: number;
  11507. /**
  11508. * The location of pick collision
  11509. */
  11510. pickedPoint: Nullable<Vector3>;
  11511. /**
  11512. * The mesh corresponding the the pick collision
  11513. */
  11514. pickedMesh: Nullable<AbstractMesh>;
  11515. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11516. bu: number;
  11517. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11518. bv: number;
  11519. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11520. faceId: number;
  11521. /** Id of the the submesh that was picked */
  11522. subMeshId: number;
  11523. /** If a sprite was picked, this will be the sprite the pick collided with */
  11524. pickedSprite: Nullable<Sprite>;
  11525. /**
  11526. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11527. */
  11528. originMesh: Nullable<AbstractMesh>;
  11529. /**
  11530. * The ray that was used to perform the picking.
  11531. */
  11532. ray: Nullable<Ray>;
  11533. /**
  11534. * Gets the normal correspodning to the face the pick collided with
  11535. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11536. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11537. * @returns The normal correspodning to the face the pick collided with
  11538. */
  11539. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11540. /**
  11541. * Gets the texture coordinates of where the pick occured
  11542. * @returns the vector containing the coordnates of the texture
  11543. */
  11544. getTextureCoordinates(): Nullable<Vector2>;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Gather the list of pointer event types as constants.
  11550. */
  11551. export class PointerEventTypes {
  11552. /**
  11553. * 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.
  11554. */
  11555. static readonly POINTERDOWN: number;
  11556. /**
  11557. * The pointerup event is fired when a pointer is no longer active.
  11558. */
  11559. static readonly POINTERUP: number;
  11560. /**
  11561. * The pointermove event is fired when a pointer changes coordinates.
  11562. */
  11563. static readonly POINTERMOVE: number;
  11564. /**
  11565. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11566. */
  11567. static readonly POINTERWHEEL: number;
  11568. /**
  11569. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11570. */
  11571. static readonly POINTERPICK: number;
  11572. /**
  11573. * The pointertap event is fired when a the object has been touched and released without drag.
  11574. */
  11575. static readonly POINTERTAP: number;
  11576. /**
  11577. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11578. */
  11579. static readonly POINTERDOUBLETAP: number;
  11580. }
  11581. /**
  11582. * Base class of pointer info types.
  11583. */
  11584. export class PointerInfoBase {
  11585. /**
  11586. * Defines the type of event (PointerEventTypes)
  11587. */
  11588. type: number;
  11589. /**
  11590. * Defines the related dom event
  11591. */
  11592. event: PointerEvent | MouseWheelEvent;
  11593. /**
  11594. * Instantiates the base class of pointers info.
  11595. * @param type Defines the type of event (PointerEventTypes)
  11596. * @param event Defines the related dom event
  11597. */
  11598. constructor(
  11599. /**
  11600. * Defines the type of event (PointerEventTypes)
  11601. */
  11602. type: number,
  11603. /**
  11604. * Defines the related dom event
  11605. */
  11606. event: PointerEvent | MouseWheelEvent);
  11607. }
  11608. /**
  11609. * This class is used to store pointer related info for the onPrePointerObservable event.
  11610. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11611. */
  11612. export class PointerInfoPre extends PointerInfoBase {
  11613. /**
  11614. * Ray from a pointer if availible (eg. 6dof controller)
  11615. */
  11616. ray: Nullable<Ray>;
  11617. /**
  11618. * Defines the local position of the pointer on the canvas.
  11619. */
  11620. localPosition: Vector2;
  11621. /**
  11622. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11623. */
  11624. skipOnPointerObservable: boolean;
  11625. /**
  11626. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11627. * @param type Defines the type of event (PointerEventTypes)
  11628. * @param event Defines the related dom event
  11629. * @param localX Defines the local x coordinates of the pointer when the event occured
  11630. * @param localY Defines the local y coordinates of the pointer when the event occured
  11631. */
  11632. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11633. }
  11634. /**
  11635. * This type contains all the data related to a pointer event in Babylon.js.
  11636. * 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.
  11637. */
  11638. export class PointerInfo extends PointerInfoBase {
  11639. /**
  11640. * Defines the picking info associated to the info (if any)\
  11641. */
  11642. pickInfo: Nullable<PickingInfo>;
  11643. /**
  11644. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11645. * @param type Defines the type of event (PointerEventTypes)
  11646. * @param event Defines the related dom event
  11647. * @param pickInfo Defines the picking info associated to the info (if any)\
  11648. */
  11649. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11650. /**
  11651. * Defines the picking info associated to the info (if any)\
  11652. */
  11653. pickInfo: Nullable<PickingInfo>);
  11654. }
  11655. /**
  11656. * Data relating to a touch event on the screen.
  11657. */
  11658. export interface PointerTouch {
  11659. /**
  11660. * X coordinate of touch.
  11661. */
  11662. x: number;
  11663. /**
  11664. * Y coordinate of touch.
  11665. */
  11666. y: number;
  11667. /**
  11668. * Id of touch. Unique for each finger.
  11669. */
  11670. pointerId: number;
  11671. /**
  11672. * Event type passed from DOM.
  11673. */
  11674. type: any;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Manage the mouse inputs to control the movement of a free camera.
  11680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11681. */
  11682. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11683. /**
  11684. * Define if touch is enabled in the mouse input
  11685. */
  11686. touchEnabled: boolean;
  11687. /**
  11688. * Defines the camera the input is attached to.
  11689. */
  11690. camera: FreeCamera;
  11691. /**
  11692. * Defines the buttons associated with the input to handle camera move.
  11693. */
  11694. buttons: number[];
  11695. /**
  11696. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11697. */
  11698. angularSensibility: number;
  11699. private _pointerInput;
  11700. private _onMouseMove;
  11701. private _observer;
  11702. private previousPosition;
  11703. /**
  11704. * Observable for when a pointer move event occurs containing the move offset
  11705. */
  11706. onPointerMovedObservable: Observable<{
  11707. offsetX: number;
  11708. offsetY: number;
  11709. }>;
  11710. /**
  11711. * @hidden
  11712. * If the camera should be rotated automatically based on pointer movement
  11713. */
  11714. _allowCameraRotation: boolean;
  11715. /**
  11716. * Manage the mouse inputs to control the movement of a free camera.
  11717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11718. * @param touchEnabled Defines if touch is enabled or not
  11719. */
  11720. constructor(
  11721. /**
  11722. * Define if touch is enabled in the mouse input
  11723. */
  11724. touchEnabled?: boolean);
  11725. /**
  11726. * Attach the input controls to a specific dom element to get the input from.
  11727. * @param element Defines the element the controls should be listened from
  11728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11729. */
  11730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11731. /**
  11732. * Called on JS contextmenu event.
  11733. * Override this method to provide functionality.
  11734. */
  11735. protected onContextMenu(evt: PointerEvent): void;
  11736. /**
  11737. * Detach the current controls from the specified dom element.
  11738. * @param element Defines the element to stop listening the inputs from
  11739. */
  11740. detachControl(element: Nullable<HTMLElement>): void;
  11741. /**
  11742. * Gets the class name of the current intput.
  11743. * @returns the class name
  11744. */
  11745. getClassName(): string;
  11746. /**
  11747. * Get the friendly name associated with the input class.
  11748. * @returns the input friendly name
  11749. */
  11750. getSimpleName(): string;
  11751. }
  11752. }
  11753. declare module BABYLON {
  11754. /**
  11755. * Manage the touch inputs to control the movement of a free camera.
  11756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11757. */
  11758. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11759. /**
  11760. * Defines the camera the input is attached to.
  11761. */
  11762. camera: FreeCamera;
  11763. /**
  11764. * Defines the touch sensibility for rotation.
  11765. * The higher the faster.
  11766. */
  11767. touchAngularSensibility: number;
  11768. /**
  11769. * Defines the touch sensibility for move.
  11770. * The higher the faster.
  11771. */
  11772. touchMoveSensibility: number;
  11773. private _offsetX;
  11774. private _offsetY;
  11775. private _pointerPressed;
  11776. private _pointerInput;
  11777. private _observer;
  11778. private _onLostFocus;
  11779. /**
  11780. * Attach the input controls to a specific dom element to get the input from.
  11781. * @param element Defines the element the controls should be listened from
  11782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11783. */
  11784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11785. /**
  11786. * Detach the current controls from the specified dom element.
  11787. * @param element Defines the element to stop listening the inputs from
  11788. */
  11789. detachControl(element: Nullable<HTMLElement>): void;
  11790. /**
  11791. * Update the current camera state depending on the inputs that have been used this frame.
  11792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11793. */
  11794. checkInputs(): void;
  11795. /**
  11796. * Gets the class name of the current intput.
  11797. * @returns the class name
  11798. */
  11799. getClassName(): string;
  11800. /**
  11801. * Get the friendly name associated with the input class.
  11802. * @returns the input friendly name
  11803. */
  11804. getSimpleName(): string;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * Default Inputs manager for the FreeCamera.
  11810. * It groups all the default supported inputs for ease of use.
  11811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11812. */
  11813. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11814. /**
  11815. * @hidden
  11816. */
  11817. _mouseInput: Nullable<FreeCameraMouseInput>;
  11818. /**
  11819. * Instantiates a new FreeCameraInputsManager.
  11820. * @param camera Defines the camera the inputs belong to
  11821. */
  11822. constructor(camera: FreeCamera);
  11823. /**
  11824. * Add keyboard input support to the input manager.
  11825. * @returns the current input manager
  11826. */
  11827. addKeyboard(): FreeCameraInputsManager;
  11828. /**
  11829. * Add mouse input support to the input manager.
  11830. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11831. * @returns the current input manager
  11832. */
  11833. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11834. /**
  11835. * Removes the mouse input support from the manager
  11836. * @returns the current input manager
  11837. */
  11838. removeMouse(): FreeCameraInputsManager;
  11839. /**
  11840. * Add touch input support to the input manager.
  11841. * @returns the current input manager
  11842. */
  11843. addTouch(): FreeCameraInputsManager;
  11844. /**
  11845. * Remove all attached input methods from a camera
  11846. */
  11847. clear(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11853. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11854. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11855. */
  11856. export class FreeCamera extends TargetCamera {
  11857. /**
  11858. * Define the collision ellipsoid of the camera.
  11859. * This is helpful to simulate a camera body like the player body around the camera
  11860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11861. */
  11862. ellipsoid: Vector3;
  11863. /**
  11864. * Define an offset for the position of the ellipsoid around the camera.
  11865. * This can be helpful to determine the center of the body near the gravity center of the body
  11866. * instead of its head.
  11867. */
  11868. ellipsoidOffset: Vector3;
  11869. /**
  11870. * Enable or disable collisions of the camera with the rest of the scene objects.
  11871. */
  11872. checkCollisions: boolean;
  11873. /**
  11874. * Enable or disable gravity on the camera.
  11875. */
  11876. applyGravity: boolean;
  11877. /**
  11878. * Define the input manager associated to the camera.
  11879. */
  11880. inputs: FreeCameraInputsManager;
  11881. /**
  11882. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11883. * Higher values reduce sensitivity.
  11884. */
  11885. /**
  11886. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11887. * Higher values reduce sensitivity.
  11888. */
  11889. angularSensibility: number;
  11890. /**
  11891. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11892. */
  11893. keysUp: number[];
  11894. /**
  11895. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11896. */
  11897. keysDown: number[];
  11898. /**
  11899. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11900. */
  11901. keysLeft: number[];
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11904. */
  11905. keysRight: number[];
  11906. /**
  11907. * Event raised when the camera collide with a mesh in the scene.
  11908. */
  11909. onCollide: (collidedMesh: AbstractMesh) => void;
  11910. private _collider;
  11911. private _needMoveForGravity;
  11912. private _oldPosition;
  11913. private _diffPosition;
  11914. private _newPosition;
  11915. /** @hidden */
  11916. _localDirection: Vector3;
  11917. /** @hidden */
  11918. _transformedDirection: Vector3;
  11919. /**
  11920. * Instantiates a Free Camera.
  11921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11922. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11924. * @param name Define the name of the camera in the scene
  11925. * @param position Define the start position of the camera in the scene
  11926. * @param scene Define the scene the camera belongs to
  11927. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11928. */
  11929. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11930. /**
  11931. * Attached controls to the current camera.
  11932. * @param element Defines the element the controls should be listened from
  11933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11934. */
  11935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11936. /**
  11937. * Detach the current controls from the camera.
  11938. * The camera will stop reacting to inputs.
  11939. * @param element Defines the element to stop listening the inputs from
  11940. */
  11941. detachControl(element: HTMLElement): void;
  11942. private _collisionMask;
  11943. /**
  11944. * Define a collision mask to limit the list of object the camera can collide with
  11945. */
  11946. collisionMask: number;
  11947. /** @hidden */
  11948. _collideWithWorld(displacement: Vector3): void;
  11949. private _onCollisionPositionChange;
  11950. /** @hidden */
  11951. _checkInputs(): void;
  11952. /** @hidden */
  11953. _decideIfNeedsToMove(): boolean;
  11954. /** @hidden */
  11955. _updatePosition(): void;
  11956. /**
  11957. * Destroy the camera and release the current resources hold by it.
  11958. */
  11959. dispose(): void;
  11960. /**
  11961. * Gets the current object class name.
  11962. * @return the class name
  11963. */
  11964. getClassName(): string;
  11965. }
  11966. }
  11967. declare module BABYLON {
  11968. /**
  11969. * Represents a gamepad control stick position
  11970. */
  11971. export class StickValues {
  11972. /**
  11973. * The x component of the control stick
  11974. */
  11975. x: number;
  11976. /**
  11977. * The y component of the control stick
  11978. */
  11979. y: number;
  11980. /**
  11981. * Initializes the gamepad x and y control stick values
  11982. * @param x The x component of the gamepad control stick value
  11983. * @param y The y component of the gamepad control stick value
  11984. */
  11985. constructor(
  11986. /**
  11987. * The x component of the control stick
  11988. */
  11989. x: number,
  11990. /**
  11991. * The y component of the control stick
  11992. */
  11993. y: number);
  11994. }
  11995. /**
  11996. * An interface which manages callbacks for gamepad button changes
  11997. */
  11998. export interface GamepadButtonChanges {
  11999. /**
  12000. * Called when a gamepad has been changed
  12001. */
  12002. changed: boolean;
  12003. /**
  12004. * Called when a gamepad press event has been triggered
  12005. */
  12006. pressChanged: boolean;
  12007. /**
  12008. * Called when a touch event has been triggered
  12009. */
  12010. touchChanged: boolean;
  12011. /**
  12012. * Called when a value has changed
  12013. */
  12014. valueChanged: boolean;
  12015. }
  12016. /**
  12017. * Represents a gamepad
  12018. */
  12019. export class Gamepad {
  12020. /**
  12021. * The id of the gamepad
  12022. */
  12023. id: string;
  12024. /**
  12025. * The index of the gamepad
  12026. */
  12027. index: number;
  12028. /**
  12029. * The browser gamepad
  12030. */
  12031. browserGamepad: any;
  12032. /**
  12033. * Specifies what type of gamepad this represents
  12034. */
  12035. type: number;
  12036. private _leftStick;
  12037. private _rightStick;
  12038. /** @hidden */
  12039. _isConnected: boolean;
  12040. private _leftStickAxisX;
  12041. private _leftStickAxisY;
  12042. private _rightStickAxisX;
  12043. private _rightStickAxisY;
  12044. /**
  12045. * Triggered when the left control stick has been changed
  12046. */
  12047. private _onleftstickchanged;
  12048. /**
  12049. * Triggered when the right control stick has been changed
  12050. */
  12051. private _onrightstickchanged;
  12052. /**
  12053. * Represents a gamepad controller
  12054. */
  12055. static GAMEPAD: number;
  12056. /**
  12057. * Represents a generic controller
  12058. */
  12059. static GENERIC: number;
  12060. /**
  12061. * Represents an XBox controller
  12062. */
  12063. static XBOX: number;
  12064. /**
  12065. * Represents a pose-enabled controller
  12066. */
  12067. static POSE_ENABLED: number;
  12068. /**
  12069. * Represents an Dual Shock controller
  12070. */
  12071. static DUALSHOCK: number;
  12072. /**
  12073. * Specifies whether the left control stick should be Y-inverted
  12074. */
  12075. protected _invertLeftStickY: boolean;
  12076. /**
  12077. * Specifies if the gamepad has been connected
  12078. */
  12079. readonly isConnected: boolean;
  12080. /**
  12081. * Initializes the gamepad
  12082. * @param id The id of the gamepad
  12083. * @param index The index of the gamepad
  12084. * @param browserGamepad The browser gamepad
  12085. * @param leftStickX The x component of the left joystick
  12086. * @param leftStickY The y component of the left joystick
  12087. * @param rightStickX The x component of the right joystick
  12088. * @param rightStickY The y component of the right joystick
  12089. */
  12090. constructor(
  12091. /**
  12092. * The id of the gamepad
  12093. */
  12094. id: string,
  12095. /**
  12096. * The index of the gamepad
  12097. */
  12098. index: number,
  12099. /**
  12100. * The browser gamepad
  12101. */
  12102. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12103. /**
  12104. * Callback triggered when the left joystick has changed
  12105. * @param callback
  12106. */
  12107. onleftstickchanged(callback: (values: StickValues) => void): void;
  12108. /**
  12109. * Callback triggered when the right joystick has changed
  12110. * @param callback
  12111. */
  12112. onrightstickchanged(callback: (values: StickValues) => void): void;
  12113. /**
  12114. * Gets the left joystick
  12115. */
  12116. /**
  12117. * Sets the left joystick values
  12118. */
  12119. leftStick: StickValues;
  12120. /**
  12121. * Gets the right joystick
  12122. */
  12123. /**
  12124. * Sets the right joystick value
  12125. */
  12126. rightStick: StickValues;
  12127. /**
  12128. * Updates the gamepad joystick positions
  12129. */
  12130. update(): void;
  12131. /**
  12132. * Disposes the gamepad
  12133. */
  12134. dispose(): void;
  12135. }
  12136. /**
  12137. * Represents a generic gamepad
  12138. */
  12139. export class GenericPad extends Gamepad {
  12140. private _buttons;
  12141. private _onbuttondown;
  12142. private _onbuttonup;
  12143. /**
  12144. * Observable triggered when a button has been pressed
  12145. */
  12146. onButtonDownObservable: Observable<number>;
  12147. /**
  12148. * Observable triggered when a button has been released
  12149. */
  12150. onButtonUpObservable: Observable<number>;
  12151. /**
  12152. * Callback triggered when a button has been pressed
  12153. * @param callback Called when a button has been pressed
  12154. */
  12155. onbuttondown(callback: (buttonPressed: number) => void): void;
  12156. /**
  12157. * Callback triggered when a button has been released
  12158. * @param callback Called when a button has been released
  12159. */
  12160. onbuttonup(callback: (buttonReleased: number) => void): void;
  12161. /**
  12162. * Initializes the generic gamepad
  12163. * @param id The id of the generic gamepad
  12164. * @param index The index of the generic gamepad
  12165. * @param browserGamepad The browser gamepad
  12166. */
  12167. constructor(id: string, index: number, browserGamepad: any);
  12168. private _setButtonValue;
  12169. /**
  12170. * Updates the generic gamepad
  12171. */
  12172. update(): void;
  12173. /**
  12174. * Disposes the generic gamepad
  12175. */
  12176. dispose(): void;
  12177. }
  12178. }
  12179. declare module BABYLON {
  12180. interface Engine {
  12181. /**
  12182. * Creates a raw texture
  12183. * @param data defines the data to store in the texture
  12184. * @param width defines the width of the texture
  12185. * @param height defines the height of the texture
  12186. * @param format defines the format of the data
  12187. * @param generateMipMaps defines if the engine should generate the mip levels
  12188. * @param invertY defines if data must be stored with Y axis inverted
  12189. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12190. * @param compression defines the compression used (null by default)
  12191. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12192. * @returns the raw texture inside an InternalTexture
  12193. */
  12194. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12195. /**
  12196. * Update a raw texture
  12197. * @param texture defines the texture to update
  12198. * @param data defines the data to store in the texture
  12199. * @param format defines the format of the data
  12200. * @param invertY defines if data must be stored with Y axis inverted
  12201. */
  12202. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12203. /**
  12204. * Update a raw texture
  12205. * @param texture defines the texture to update
  12206. * @param data defines the data to store in the texture
  12207. * @param format defines the format of the data
  12208. * @param invertY defines if data must be stored with Y axis inverted
  12209. * @param compression defines the compression used (null by default)
  12210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12211. */
  12212. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12213. /**
  12214. * Creates a new raw cube texture
  12215. * @param data defines the array of data to use to create each face
  12216. * @param size defines the size of the textures
  12217. * @param format defines the format of the data
  12218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12219. * @param generateMipMaps defines if the engine should generate the mip levels
  12220. * @param invertY defines if data must be stored with Y axis inverted
  12221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12222. * @param compression defines the compression used (null by default)
  12223. * @returns the cube texture as an InternalTexture
  12224. */
  12225. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12226. /**
  12227. * Update a raw cube texture
  12228. * @param texture defines the texture to udpdate
  12229. * @param data defines the data to store
  12230. * @param format defines the data format
  12231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12232. * @param invertY defines if data must be stored with Y axis inverted
  12233. */
  12234. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12235. /**
  12236. * Update a raw cube texture
  12237. * @param texture defines the texture to udpdate
  12238. * @param data defines the data to store
  12239. * @param format defines the data format
  12240. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12241. * @param invertY defines if data must be stored with Y axis inverted
  12242. * @param compression defines the compression used (null by default)
  12243. */
  12244. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12245. /**
  12246. * Update a raw cube texture
  12247. * @param texture defines the texture to udpdate
  12248. * @param data defines the data to store
  12249. * @param format defines the data format
  12250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12251. * @param invertY defines if data must be stored with Y axis inverted
  12252. * @param compression defines the compression used (null by default)
  12253. * @param level defines which level of the texture to update
  12254. */
  12255. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12256. /**
  12257. * Creates a new raw cube texture from a specified url
  12258. * @param url defines the url where the data is located
  12259. * @param scene defines the current scene
  12260. * @param size defines the size of the textures
  12261. * @param format defines the format of the data
  12262. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12263. * @param noMipmap defines if the engine should avoid generating the mip levels
  12264. * @param callback defines a callback used to extract texture data from loaded data
  12265. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12266. * @param onLoad defines a callback called when texture is loaded
  12267. * @param onError defines a callback called if there is an error
  12268. * @returns the cube texture as an InternalTexture
  12269. */
  12270. 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;
  12271. /**
  12272. * Creates a new raw cube texture from a specified url
  12273. * @param url defines the url where the data is located
  12274. * @param scene defines the current scene
  12275. * @param size defines the size of the textures
  12276. * @param format defines the format of the data
  12277. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12278. * @param noMipmap defines if the engine should avoid generating the mip levels
  12279. * @param callback defines a callback used to extract texture data from loaded data
  12280. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12281. * @param onLoad defines a callback called when texture is loaded
  12282. * @param onError defines a callback called if there is an error
  12283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12284. * @param invertY defines if data must be stored with Y axis inverted
  12285. * @returns the cube texture as an InternalTexture
  12286. */
  12287. 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;
  12288. /**
  12289. * Creates a new raw 3D texture
  12290. * @param data defines the data used to create the texture
  12291. * @param width defines the width of the texture
  12292. * @param height defines the height of the texture
  12293. * @param depth defines the depth of the texture
  12294. * @param format defines the format of the texture
  12295. * @param generateMipMaps defines if the engine must generate mip levels
  12296. * @param invertY defines if data must be stored with Y axis inverted
  12297. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12298. * @param compression defines the compressed used (can be null)
  12299. * @param textureType defines the compressed used (can be null)
  12300. * @returns a new raw 3D texture (stored in an InternalTexture)
  12301. */
  12302. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12303. /**
  12304. * Update a raw 3D texture
  12305. * @param texture defines the texture to update
  12306. * @param data defines the data to store
  12307. * @param format defines the data format
  12308. * @param invertY defines if data must be stored with Y axis inverted
  12309. */
  12310. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12311. /**
  12312. * Update a raw 3D texture
  12313. * @param texture defines the texture to update
  12314. * @param data defines the data to store
  12315. * @param format defines the data format
  12316. * @param invertY defines if data must be stored with Y axis inverted
  12317. * @param compression defines the used compression (can be null)
  12318. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12319. */
  12320. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12321. }
  12322. }
  12323. declare module BABYLON {
  12324. /**
  12325. * Raw texture can help creating a texture directly from an array of data.
  12326. * This can be super useful if you either get the data from an uncompressed source or
  12327. * if you wish to create your texture pixel by pixel.
  12328. */
  12329. export class RawTexture extends Texture {
  12330. /**
  12331. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12332. */
  12333. format: number;
  12334. private _engine;
  12335. /**
  12336. * Instantiates a new RawTexture.
  12337. * Raw texture can help creating a texture directly from an array of data.
  12338. * This can be super useful if you either get the data from an uncompressed source or
  12339. * if you wish to create your texture pixel by pixel.
  12340. * @param data define the array of data to use to create the texture
  12341. * @param width define the width of the texture
  12342. * @param height define the height of the texture
  12343. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12344. * @param scene define the scene the texture belongs to
  12345. * @param generateMipMaps define whether mip maps should be generated or not
  12346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12348. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12349. */
  12350. constructor(data: ArrayBufferView, width: number, height: number,
  12351. /**
  12352. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12353. */
  12354. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12355. /**
  12356. * Updates the texture underlying data.
  12357. * @param data Define the new data of the texture
  12358. */
  12359. update(data: ArrayBufferView): void;
  12360. /**
  12361. * Creates a luminance texture from some data.
  12362. * @param data Define the texture data
  12363. * @param width Define the width of the texture
  12364. * @param height Define the height of the texture
  12365. * @param scene Define the scene the texture belongs to
  12366. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12367. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12368. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12369. * @returns the luminance texture
  12370. */
  12371. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12372. /**
  12373. * Creates a luminance alpha texture from some data.
  12374. * @param data Define the texture data
  12375. * @param width Define the width of the texture
  12376. * @param height Define the height of the texture
  12377. * @param scene Define the scene the texture belongs to
  12378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12381. * @returns the luminance alpha texture
  12382. */
  12383. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12384. /**
  12385. * Creates an alpha texture from some data.
  12386. * @param data Define the texture data
  12387. * @param width Define the width of the texture
  12388. * @param height Define the height of the texture
  12389. * @param scene Define the scene the texture belongs to
  12390. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12391. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12392. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12393. * @returns the alpha texture
  12394. */
  12395. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12396. /**
  12397. * Creates a RGB texture from some data.
  12398. * @param data Define the texture data
  12399. * @param width Define the width of the texture
  12400. * @param height Define the height of the texture
  12401. * @param scene Define the scene the texture belongs to
  12402. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12403. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12404. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12405. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12406. * @returns the RGB alpha texture
  12407. */
  12408. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12409. /**
  12410. * Creates a RGBA texture from some data.
  12411. * @param data Define the texture data
  12412. * @param width Define the width of the texture
  12413. * @param height Define the height of the texture
  12414. * @param scene Define the scene the texture belongs to
  12415. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12416. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12417. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12418. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12419. * @returns the RGBA texture
  12420. */
  12421. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12422. /**
  12423. * Creates a R 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12432. * @returns the R texture
  12433. */
  12434. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12435. }
  12436. }
  12437. declare module BABYLON {
  12438. /**
  12439. * Interface for the size containing width and height
  12440. */
  12441. export interface ISize {
  12442. /**
  12443. * Width
  12444. */
  12445. width: number;
  12446. /**
  12447. * Heighht
  12448. */
  12449. height: number;
  12450. }
  12451. /**
  12452. * Size containing widht and height
  12453. */
  12454. export class Size implements ISize {
  12455. /**
  12456. * Width
  12457. */
  12458. width: number;
  12459. /**
  12460. * Height
  12461. */
  12462. height: number;
  12463. /**
  12464. * Creates a Size object from the given width and height (floats).
  12465. * @param width width of the new size
  12466. * @param height height of the new size
  12467. */
  12468. constructor(width: number, height: number);
  12469. /**
  12470. * Returns a string with the Size width and height
  12471. * @returns a string with the Size width and height
  12472. */
  12473. toString(): string;
  12474. /**
  12475. * "Size"
  12476. * @returns the string "Size"
  12477. */
  12478. getClassName(): string;
  12479. /**
  12480. * Returns the Size hash code.
  12481. * @returns a hash code for a unique width and height
  12482. */
  12483. getHashCode(): number;
  12484. /**
  12485. * Updates the current size from the given one.
  12486. * @param src the given size
  12487. */
  12488. copyFrom(src: Size): void;
  12489. /**
  12490. * Updates in place the current Size from the given floats.
  12491. * @param width width of the new size
  12492. * @param height height of the new size
  12493. * @returns the updated Size.
  12494. */
  12495. copyFromFloats(width: number, height: number): Size;
  12496. /**
  12497. * Updates in place the current Size from the given floats.
  12498. * @param width width to set
  12499. * @param height height to set
  12500. * @returns the updated Size.
  12501. */
  12502. set(width: number, height: number): Size;
  12503. /**
  12504. * Multiplies the width and height by numbers
  12505. * @param w factor to multiple the width by
  12506. * @param h factor to multiple the height by
  12507. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12508. */
  12509. multiplyByFloats(w: number, h: number): Size;
  12510. /**
  12511. * Clones the size
  12512. * @returns a new Size copied from the given one.
  12513. */
  12514. clone(): Size;
  12515. /**
  12516. * True if the current Size and the given one width and height are strictly equal.
  12517. * @param other the other size to compare against
  12518. * @returns True if the current Size and the given one width and height are strictly equal.
  12519. */
  12520. equals(other: Size): boolean;
  12521. /**
  12522. * The surface of the Size : width * height (float).
  12523. */
  12524. readonly surface: number;
  12525. /**
  12526. * Create a new size of zero
  12527. * @returns a new Size set to (0.0, 0.0)
  12528. */
  12529. static Zero(): Size;
  12530. /**
  12531. * Sums the width and height of two sizes
  12532. * @param otherSize size to add to this size
  12533. * @returns a new Size set as the addition result of the current Size and the given one.
  12534. */
  12535. add(otherSize: Size): Size;
  12536. /**
  12537. * Subtracts the width and height of two
  12538. * @param otherSize size to subtract to this size
  12539. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12540. */
  12541. subtract(otherSize: Size): Size;
  12542. /**
  12543. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12544. * @param start starting size to lerp between
  12545. * @param end end size to lerp between
  12546. * @param amount amount to lerp between the start and end values
  12547. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12548. */
  12549. static Lerp(start: Size, end: Size, amount: number): Size;
  12550. }
  12551. }
  12552. declare module BABYLON {
  12553. /**
  12554. * Defines a runtime animation
  12555. */
  12556. export class RuntimeAnimation {
  12557. private _events;
  12558. /**
  12559. * The current frame of the runtime animation
  12560. */
  12561. private _currentFrame;
  12562. /**
  12563. * The animation used by the runtime animation
  12564. */
  12565. private _animation;
  12566. /**
  12567. * The target of the runtime animation
  12568. */
  12569. private _target;
  12570. /**
  12571. * The initiating animatable
  12572. */
  12573. private _host;
  12574. /**
  12575. * The original value of the runtime animation
  12576. */
  12577. private _originalValue;
  12578. /**
  12579. * The original blend value of the runtime animation
  12580. */
  12581. private _originalBlendValue;
  12582. /**
  12583. * The offsets cache of the runtime animation
  12584. */
  12585. private _offsetsCache;
  12586. /**
  12587. * The high limits cache of the runtime animation
  12588. */
  12589. private _highLimitsCache;
  12590. /**
  12591. * Specifies if the runtime animation has been stopped
  12592. */
  12593. private _stopped;
  12594. /**
  12595. * The blending factor of the runtime animation
  12596. */
  12597. private _blendingFactor;
  12598. /**
  12599. * The BabylonJS scene
  12600. */
  12601. private _scene;
  12602. /**
  12603. * The current value of the runtime animation
  12604. */
  12605. private _currentValue;
  12606. /** @hidden */
  12607. _animationState: _IAnimationState;
  12608. /**
  12609. * The active target of the runtime animation
  12610. */
  12611. private _activeTargets;
  12612. private _currentActiveTarget;
  12613. private _directTarget;
  12614. /**
  12615. * The target path of the runtime animation
  12616. */
  12617. private _targetPath;
  12618. /**
  12619. * The weight of the runtime animation
  12620. */
  12621. private _weight;
  12622. /**
  12623. * The ratio offset of the runtime animation
  12624. */
  12625. private _ratioOffset;
  12626. /**
  12627. * The previous delay of the runtime animation
  12628. */
  12629. private _previousDelay;
  12630. /**
  12631. * The previous ratio of the runtime animation
  12632. */
  12633. private _previousRatio;
  12634. private _enableBlending;
  12635. private _keys;
  12636. private _minFrame;
  12637. private _maxFrame;
  12638. private _minValue;
  12639. private _maxValue;
  12640. private _targetIsArray;
  12641. /**
  12642. * Gets the current frame of the runtime animation
  12643. */
  12644. readonly currentFrame: number;
  12645. /**
  12646. * Gets the weight of the runtime animation
  12647. */
  12648. readonly weight: number;
  12649. /**
  12650. * Gets the current value of the runtime animation
  12651. */
  12652. readonly currentValue: any;
  12653. /**
  12654. * Gets the target path of the runtime animation
  12655. */
  12656. readonly targetPath: string;
  12657. /**
  12658. * Gets the actual target of the runtime animation
  12659. */
  12660. readonly target: any;
  12661. /** @hidden */
  12662. _onLoop: () => void;
  12663. /**
  12664. * Create a new RuntimeAnimation object
  12665. * @param target defines the target of the animation
  12666. * @param animation defines the source animation object
  12667. * @param scene defines the hosting scene
  12668. * @param host defines the initiating Animatable
  12669. */
  12670. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12671. private _preparePath;
  12672. /**
  12673. * Gets the animation from the runtime animation
  12674. */
  12675. readonly animation: Animation;
  12676. /**
  12677. * Resets the runtime animation to the beginning
  12678. * @param restoreOriginal defines whether to restore the target property to the original value
  12679. */
  12680. reset(restoreOriginal?: boolean): void;
  12681. /**
  12682. * Specifies if the runtime animation is stopped
  12683. * @returns Boolean specifying if the runtime animation is stopped
  12684. */
  12685. isStopped(): boolean;
  12686. /**
  12687. * Disposes of the runtime animation
  12688. */
  12689. dispose(): void;
  12690. /**
  12691. * Apply the interpolated value to the target
  12692. * @param currentValue defines the value computed by the animation
  12693. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12694. */
  12695. setValue(currentValue: any, weight: number): void;
  12696. private _getOriginalValues;
  12697. private _setValue;
  12698. /**
  12699. * Gets the loop pmode of the runtime animation
  12700. * @returns Loop Mode
  12701. */
  12702. private _getCorrectLoopMode;
  12703. /**
  12704. * Move the current animation to a given frame
  12705. * @param frame defines the frame to move to
  12706. */
  12707. goToFrame(frame: number): void;
  12708. /**
  12709. * @hidden Internal use only
  12710. */
  12711. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12712. /**
  12713. * Execute the current animation
  12714. * @param delay defines the delay to add to the current frame
  12715. * @param from defines the lower bound of the animation range
  12716. * @param to defines the upper bound of the animation range
  12717. * @param loop defines if the current animation must loop
  12718. * @param speedRatio defines the current speed ratio
  12719. * @param weight defines the weight of the animation (default is -1 so no weight)
  12720. * @param onLoop optional callback called when animation loops
  12721. * @returns a boolean indicating if the animation is running
  12722. */
  12723. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12724. }
  12725. }
  12726. declare module BABYLON {
  12727. /**
  12728. * Class used to store an actual running animation
  12729. */
  12730. export class Animatable {
  12731. /** defines the target object */
  12732. target: any;
  12733. /** defines the starting frame number (default is 0) */
  12734. fromFrame: number;
  12735. /** defines the ending frame number (default is 100) */
  12736. toFrame: number;
  12737. /** defines if the animation must loop (default is false) */
  12738. loopAnimation: boolean;
  12739. /** defines a callback to call when animation ends if it is not looping */
  12740. onAnimationEnd?: (() => void) | null | undefined;
  12741. /** defines a callback to call when animation loops */
  12742. onAnimationLoop?: (() => void) | null | undefined;
  12743. private _localDelayOffset;
  12744. private _pausedDelay;
  12745. private _runtimeAnimations;
  12746. private _paused;
  12747. private _scene;
  12748. private _speedRatio;
  12749. private _weight;
  12750. private _syncRoot;
  12751. /**
  12752. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12753. * This will only apply for non looping animation (default is true)
  12754. */
  12755. disposeOnEnd: boolean;
  12756. /**
  12757. * Gets a boolean indicating if the animation has started
  12758. */
  12759. animationStarted: boolean;
  12760. /**
  12761. * Observer raised when the animation ends
  12762. */
  12763. onAnimationEndObservable: Observable<Animatable>;
  12764. /**
  12765. * Observer raised when the animation loops
  12766. */
  12767. onAnimationLoopObservable: Observable<Animatable>;
  12768. /**
  12769. * Gets the root Animatable used to synchronize and normalize animations
  12770. */
  12771. readonly syncRoot: Nullable<Animatable>;
  12772. /**
  12773. * Gets the current frame of the first RuntimeAnimation
  12774. * Used to synchronize Animatables
  12775. */
  12776. readonly masterFrame: number;
  12777. /**
  12778. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12779. */
  12780. weight: number;
  12781. /**
  12782. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12783. */
  12784. speedRatio: number;
  12785. /**
  12786. * Creates a new Animatable
  12787. * @param scene defines the hosting scene
  12788. * @param target defines the target object
  12789. * @param fromFrame defines the starting frame number (default is 0)
  12790. * @param toFrame defines the ending frame number (default is 100)
  12791. * @param loopAnimation defines if the animation must loop (default is false)
  12792. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12793. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12794. * @param animations defines a group of animation to add to the new Animatable
  12795. * @param onAnimationLoop defines a callback to call when animation loops
  12796. */
  12797. constructor(scene: Scene,
  12798. /** defines the target object */
  12799. target: any,
  12800. /** defines the starting frame number (default is 0) */
  12801. fromFrame?: number,
  12802. /** defines the ending frame number (default is 100) */
  12803. toFrame?: number,
  12804. /** defines if the animation must loop (default is false) */
  12805. loopAnimation?: boolean, speedRatio?: number,
  12806. /** defines a callback to call when animation ends if it is not looping */
  12807. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12808. /** defines a callback to call when animation loops */
  12809. onAnimationLoop?: (() => void) | null | undefined);
  12810. /**
  12811. * Synchronize and normalize current Animatable with a source Animatable
  12812. * This is useful when using animation weights and when animations are not of the same length
  12813. * @param root defines the root Animatable to synchronize with
  12814. * @returns the current Animatable
  12815. */
  12816. syncWith(root: Animatable): Animatable;
  12817. /**
  12818. * Gets the list of runtime animations
  12819. * @returns an array of RuntimeAnimation
  12820. */
  12821. getAnimations(): RuntimeAnimation[];
  12822. /**
  12823. * Adds more animations to the current animatable
  12824. * @param target defines the target of the animations
  12825. * @param animations defines the new animations to add
  12826. */
  12827. appendAnimations(target: any, animations: Animation[]): void;
  12828. /**
  12829. * Gets the source animation for a specific property
  12830. * @param property defines the propertyu to look for
  12831. * @returns null or the source animation for the given property
  12832. */
  12833. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12834. /**
  12835. * Gets the runtime animation for a specific property
  12836. * @param property defines the propertyu to look for
  12837. * @returns null or the runtime animation for the given property
  12838. */
  12839. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12840. /**
  12841. * Resets the animatable to its original state
  12842. */
  12843. reset(): void;
  12844. /**
  12845. * Allows the animatable to blend with current running animations
  12846. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12847. * @param blendingSpeed defines the blending speed to use
  12848. */
  12849. enableBlending(blendingSpeed: number): void;
  12850. /**
  12851. * Disable animation blending
  12852. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12853. */
  12854. disableBlending(): void;
  12855. /**
  12856. * Jump directly to a given frame
  12857. * @param frame defines the frame to jump to
  12858. */
  12859. goToFrame(frame: number): void;
  12860. /**
  12861. * Pause the animation
  12862. */
  12863. pause(): void;
  12864. /**
  12865. * Restart the animation
  12866. */
  12867. restart(): void;
  12868. private _raiseOnAnimationEnd;
  12869. /**
  12870. * Stop and delete the current animation
  12871. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12872. * @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)
  12873. */
  12874. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12875. /**
  12876. * Wait asynchronously for the animation to end
  12877. * @returns a promise which will be fullfilled when the animation ends
  12878. */
  12879. waitAsync(): Promise<Animatable>;
  12880. /** @hidden */
  12881. _animate(delay: number): boolean;
  12882. }
  12883. interface Scene {
  12884. /** @hidden */
  12885. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12886. /** @hidden */
  12887. _processLateAnimationBindingsForMatrices(holder: {
  12888. totalWeight: number;
  12889. animations: RuntimeAnimation[];
  12890. originalValue: Matrix;
  12891. }): any;
  12892. /** @hidden */
  12893. _processLateAnimationBindingsForQuaternions(holder: {
  12894. totalWeight: number;
  12895. animations: RuntimeAnimation[];
  12896. originalValue: Quaternion;
  12897. }, refQuaternion: Quaternion): Quaternion;
  12898. /** @hidden */
  12899. _processLateAnimationBindings(): void;
  12900. /**
  12901. * Will start the animation sequence of a given target
  12902. * @param target defines the target
  12903. * @param from defines from which frame should animation start
  12904. * @param to defines until which frame should animation run.
  12905. * @param weight defines the weight to apply to the animation (1.0 by default)
  12906. * @param loop defines if the animation loops
  12907. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12908. * @param onAnimationEnd defines the function to be executed when the animation ends
  12909. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12910. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12911. * @param onAnimationLoop defines the callback to call when an animation loops
  12912. * @returns the animatable object created for this animation
  12913. */
  12914. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12915. /**
  12916. * Will start the animation sequence of a given target
  12917. * @param target defines the target
  12918. * @param from defines from which frame should animation start
  12919. * @param to defines until which frame should animation run.
  12920. * @param loop defines if the animation loops
  12921. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12922. * @param onAnimationEnd defines the function to be executed when the animation ends
  12923. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12924. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12925. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12926. * @param onAnimationLoop defines the callback to call when an animation loops
  12927. * @returns the animatable object created for this animation
  12928. */
  12929. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12930. /**
  12931. * Will start the animation sequence of a given target and its hierarchy
  12932. * @param target defines the target
  12933. * @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.
  12934. * @param from defines from which frame should animation start
  12935. * @param to defines until which frame should animation run.
  12936. * @param loop defines if the animation loops
  12937. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12938. * @param onAnimationEnd defines the function to be executed when the animation ends
  12939. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12940. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12941. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12942. * @param onAnimationLoop defines the callback to call when an animation loops
  12943. * @returns the list of created animatables
  12944. */
  12945. 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[];
  12946. /**
  12947. * Begin a new animation on a given node
  12948. * @param target defines the target where the animation will take place
  12949. * @param animations defines the list of animations to start
  12950. * @param from defines the initial value
  12951. * @param to defines the final value
  12952. * @param loop defines if you want animation to loop (off by default)
  12953. * @param speedRatio defines the speed ratio to apply to all animations
  12954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12955. * @param onAnimationLoop defines the callback to call when an animation loops
  12956. * @returns the list of created animatables
  12957. */
  12958. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12959. /**
  12960. * Begin a new animation on a given node and its hierarchy
  12961. * @param target defines the root node where the animation will take place
  12962. * @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.
  12963. * @param animations defines the list of animations to start
  12964. * @param from defines the initial value
  12965. * @param to defines the final value
  12966. * @param loop defines if you want animation to loop (off by default)
  12967. * @param speedRatio defines the speed ratio to apply to all animations
  12968. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12969. * @param onAnimationLoop defines the callback to call when an animation loops
  12970. * @returns the list of animatables created for all nodes
  12971. */
  12972. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12973. /**
  12974. * Gets the animatable associated with a specific target
  12975. * @param target defines the target of the animatable
  12976. * @returns the required animatable if found
  12977. */
  12978. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12979. /**
  12980. * Gets all animatables associated with a given target
  12981. * @param target defines the target to look animatables for
  12982. * @returns an array of Animatables
  12983. */
  12984. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12985. /**
  12986. * Stops and removes all animations that have been applied to the scene
  12987. */
  12988. stopAllAnimations(): void;
  12989. }
  12990. interface Bone {
  12991. /**
  12992. * Copy an animation range from another bone
  12993. * @param source defines the source bone
  12994. * @param rangeName defines the range name to copy
  12995. * @param frameOffset defines the frame offset
  12996. * @param rescaleAsRequired defines if rescaling must be applied if required
  12997. * @param skelDimensionsRatio defines the scaling ratio
  12998. * @returns true if operation was successful
  12999. */
  13000. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13001. }
  13002. }
  13003. declare module BABYLON {
  13004. /**
  13005. * Class used to override all child animations of a given target
  13006. */
  13007. export class AnimationPropertiesOverride {
  13008. /**
  13009. * Gets or sets a value indicating if animation blending must be used
  13010. */
  13011. enableBlending: boolean;
  13012. /**
  13013. * Gets or sets the blending speed to use when enableBlending is true
  13014. */
  13015. blendingSpeed: number;
  13016. /**
  13017. * Gets or sets the default loop mode to use
  13018. */
  13019. loopMode: number;
  13020. }
  13021. }
  13022. declare module BABYLON {
  13023. /**
  13024. * Class used to handle skinning animations
  13025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13026. */
  13027. export class Skeleton implements IAnimatable {
  13028. /** defines the skeleton name */
  13029. name: string;
  13030. /** defines the skeleton Id */
  13031. id: string;
  13032. /**
  13033. * Defines the list of child bones
  13034. */
  13035. bones: Bone[];
  13036. /**
  13037. * Defines an estimate of the dimension of the skeleton at rest
  13038. */
  13039. dimensionsAtRest: Vector3;
  13040. /**
  13041. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13042. */
  13043. needInitialSkinMatrix: boolean;
  13044. /**
  13045. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13046. */
  13047. overrideMesh: Nullable<AbstractMesh>;
  13048. /**
  13049. * Gets the list of animations attached to this skeleton
  13050. */
  13051. animations: Array<Animation>;
  13052. private _scene;
  13053. private _isDirty;
  13054. private _transformMatrices;
  13055. private _transformMatrixTexture;
  13056. private _meshesWithPoseMatrix;
  13057. private _animatables;
  13058. private _identity;
  13059. private _synchronizedWithMesh;
  13060. private _ranges;
  13061. private _lastAbsoluteTransformsUpdateId;
  13062. private _canUseTextureForBones;
  13063. private _uniqueId;
  13064. /** @hidden */
  13065. _numBonesWithLinkedTransformNode: number;
  13066. /** @hidden */
  13067. _hasWaitingData: Nullable<boolean>;
  13068. /**
  13069. * Specifies if the skeleton should be serialized
  13070. */
  13071. doNotSerialize: boolean;
  13072. private _useTextureToStoreBoneMatrices;
  13073. /**
  13074. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13075. * Please note that this option is not available if the hardware does not support it
  13076. */
  13077. useTextureToStoreBoneMatrices: boolean;
  13078. private _animationPropertiesOverride;
  13079. /**
  13080. * Gets or sets the animation properties override
  13081. */
  13082. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13083. /**
  13084. * List of inspectable custom properties (used by the Inspector)
  13085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13086. */
  13087. inspectableCustomProperties: IInspectable[];
  13088. /**
  13089. * An observable triggered before computing the skeleton's matrices
  13090. */
  13091. onBeforeComputeObservable: Observable<Skeleton>;
  13092. /**
  13093. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13094. */
  13095. readonly isUsingTextureForMatrices: boolean;
  13096. /**
  13097. * Gets the unique ID of this skeleton
  13098. */
  13099. readonly uniqueId: number;
  13100. /**
  13101. * Creates a new skeleton
  13102. * @param name defines the skeleton name
  13103. * @param id defines the skeleton Id
  13104. * @param scene defines the hosting scene
  13105. */
  13106. constructor(
  13107. /** defines the skeleton name */
  13108. name: string,
  13109. /** defines the skeleton Id */
  13110. id: string, scene: Scene);
  13111. /**
  13112. * Gets the current object class name.
  13113. * @return the class name
  13114. */
  13115. getClassName(): string;
  13116. /**
  13117. * Returns an array containing the root bones
  13118. * @returns an array containing the root bones
  13119. */
  13120. getChildren(): Array<Bone>;
  13121. /**
  13122. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13123. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13124. * @returns a Float32Array containing matrices data
  13125. */
  13126. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13127. /**
  13128. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13129. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13130. * @returns a raw texture containing the data
  13131. */
  13132. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13133. /**
  13134. * Gets the current hosting scene
  13135. * @returns a scene object
  13136. */
  13137. getScene(): Scene;
  13138. /**
  13139. * Gets a string representing the current skeleton data
  13140. * @param fullDetails defines a boolean indicating if we want a verbose version
  13141. * @returns a string representing the current skeleton data
  13142. */
  13143. toString(fullDetails?: boolean): string;
  13144. /**
  13145. * Get bone's index searching by name
  13146. * @param name defines bone's name to search for
  13147. * @return the indice of the bone. Returns -1 if not found
  13148. */
  13149. getBoneIndexByName(name: string): number;
  13150. /**
  13151. * Creater a new animation range
  13152. * @param name defines the name of the range
  13153. * @param from defines the start key
  13154. * @param to defines the end key
  13155. */
  13156. createAnimationRange(name: string, from: number, to: number): void;
  13157. /**
  13158. * Delete a specific animation range
  13159. * @param name defines the name of the range
  13160. * @param deleteFrames defines if frames must be removed as well
  13161. */
  13162. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13163. /**
  13164. * Gets a specific animation range
  13165. * @param name defines the name of the range to look for
  13166. * @returns the requested animation range or null if not found
  13167. */
  13168. getAnimationRange(name: string): Nullable<AnimationRange>;
  13169. /**
  13170. * Gets the list of all animation ranges defined on this skeleton
  13171. * @returns an array
  13172. */
  13173. getAnimationRanges(): Nullable<AnimationRange>[];
  13174. /**
  13175. * Copy animation range from a source skeleton.
  13176. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13177. * @param source defines the source skeleton
  13178. * @param name defines the name of the range to copy
  13179. * @param rescaleAsRequired defines if rescaling must be applied if required
  13180. * @returns true if operation was successful
  13181. */
  13182. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13183. /**
  13184. * Forces the skeleton to go to rest pose
  13185. */
  13186. returnToRest(): void;
  13187. private _getHighestAnimationFrame;
  13188. /**
  13189. * Begin a specific animation range
  13190. * @param name defines the name of the range to start
  13191. * @param loop defines if looping must be turned on (false by default)
  13192. * @param speedRatio defines the speed ratio to apply (1 by default)
  13193. * @param onAnimationEnd defines a callback which will be called when animation will end
  13194. * @returns a new animatable
  13195. */
  13196. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13197. /** @hidden */
  13198. _markAsDirty(): void;
  13199. /** @hidden */
  13200. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13201. /** @hidden */
  13202. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13203. private _computeTransformMatrices;
  13204. /**
  13205. * Build all resources required to render a skeleton
  13206. */
  13207. prepare(): void;
  13208. /**
  13209. * Gets the list of animatables currently running for this skeleton
  13210. * @returns an array of animatables
  13211. */
  13212. getAnimatables(): IAnimatable[];
  13213. /**
  13214. * Clone the current skeleton
  13215. * @param name defines the name of the new skeleton
  13216. * @param id defines the id of the new skeleton
  13217. * @returns the new skeleton
  13218. */
  13219. clone(name: string, id: string): Skeleton;
  13220. /**
  13221. * Enable animation blending for this skeleton
  13222. * @param blendingSpeed defines the blending speed to apply
  13223. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13224. */
  13225. enableBlending(blendingSpeed?: number): void;
  13226. /**
  13227. * Releases all resources associated with the current skeleton
  13228. */
  13229. dispose(): void;
  13230. /**
  13231. * Serialize the skeleton in a JSON object
  13232. * @returns a JSON object
  13233. */
  13234. serialize(): any;
  13235. /**
  13236. * Creates a new skeleton from serialized data
  13237. * @param parsedSkeleton defines the serialized data
  13238. * @param scene defines the hosting scene
  13239. * @returns a new skeleton
  13240. */
  13241. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13242. /**
  13243. * Compute all node absolute transforms
  13244. * @param forceUpdate defines if computation must be done even if cache is up to date
  13245. */
  13246. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13247. /**
  13248. * Gets the root pose matrix
  13249. * @returns a matrix
  13250. */
  13251. getPoseMatrix(): Nullable<Matrix>;
  13252. /**
  13253. * Sorts bones per internal index
  13254. */
  13255. sortBones(): void;
  13256. private _sortBones;
  13257. }
  13258. }
  13259. declare module BABYLON {
  13260. /**
  13261. * Class used to store bone information
  13262. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13263. */
  13264. export class Bone extends Node {
  13265. /**
  13266. * defines the bone name
  13267. */
  13268. name: string;
  13269. private static _tmpVecs;
  13270. private static _tmpQuat;
  13271. private static _tmpMats;
  13272. /**
  13273. * Gets the list of child bones
  13274. */
  13275. children: Bone[];
  13276. /** Gets the animations associated with this bone */
  13277. animations: Animation[];
  13278. /**
  13279. * Gets or sets bone length
  13280. */
  13281. length: number;
  13282. /**
  13283. * @hidden Internal only
  13284. * Set this value to map this bone to a different index in the transform matrices
  13285. * Set this value to -1 to exclude the bone from the transform matrices
  13286. */
  13287. _index: Nullable<number>;
  13288. private _skeleton;
  13289. private _localMatrix;
  13290. private _restPose;
  13291. private _baseMatrix;
  13292. private _absoluteTransform;
  13293. private _invertedAbsoluteTransform;
  13294. private _parent;
  13295. private _scalingDeterminant;
  13296. private _worldTransform;
  13297. private _localScaling;
  13298. private _localRotation;
  13299. private _localPosition;
  13300. private _needToDecompose;
  13301. private _needToCompose;
  13302. /** @hidden */
  13303. _linkedTransformNode: Nullable<TransformNode>;
  13304. /** @hidden */
  13305. _waitingTransformNodeId: Nullable<string>;
  13306. /** @hidden */
  13307. /** @hidden */
  13308. _matrix: Matrix;
  13309. /**
  13310. * Create a new bone
  13311. * @param name defines the bone name
  13312. * @param skeleton defines the parent skeleton
  13313. * @param parentBone defines the parent (can be null if the bone is the root)
  13314. * @param localMatrix defines the local matrix
  13315. * @param restPose defines the rest pose matrix
  13316. * @param baseMatrix defines the base matrix
  13317. * @param index defines index of the bone in the hiearchy
  13318. */
  13319. constructor(
  13320. /**
  13321. * defines the bone name
  13322. */
  13323. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13324. /**
  13325. * Gets the current object class name.
  13326. * @return the class name
  13327. */
  13328. getClassName(): string;
  13329. /**
  13330. * Gets the parent skeleton
  13331. * @returns a skeleton
  13332. */
  13333. getSkeleton(): Skeleton;
  13334. /**
  13335. * Gets parent bone
  13336. * @returns a bone or null if the bone is the root of the bone hierarchy
  13337. */
  13338. getParent(): Nullable<Bone>;
  13339. /**
  13340. * Returns an array containing the root bones
  13341. * @returns an array containing the root bones
  13342. */
  13343. getChildren(): Array<Bone>;
  13344. /**
  13345. * Sets the parent bone
  13346. * @param parent defines the parent (can be null if the bone is the root)
  13347. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13348. */
  13349. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13350. /**
  13351. * Gets the local matrix
  13352. * @returns a matrix
  13353. */
  13354. getLocalMatrix(): Matrix;
  13355. /**
  13356. * Gets the base matrix (initial matrix which remains unchanged)
  13357. * @returns a matrix
  13358. */
  13359. getBaseMatrix(): Matrix;
  13360. /**
  13361. * Gets the rest pose matrix
  13362. * @returns a matrix
  13363. */
  13364. getRestPose(): Matrix;
  13365. /**
  13366. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13367. */
  13368. getWorldMatrix(): Matrix;
  13369. /**
  13370. * Sets the local matrix to rest pose matrix
  13371. */
  13372. returnToRest(): void;
  13373. /**
  13374. * Gets the inverse of the absolute transform matrix.
  13375. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13376. * @returns a matrix
  13377. */
  13378. getInvertedAbsoluteTransform(): Matrix;
  13379. /**
  13380. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13381. * @returns a matrix
  13382. */
  13383. getAbsoluteTransform(): Matrix;
  13384. /**
  13385. * Links with the given transform node.
  13386. * The local matrix of this bone is copied from the transform node every frame.
  13387. * @param transformNode defines the transform node to link to
  13388. */
  13389. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13390. /**
  13391. * Gets the node used to drive the bone's transformation
  13392. * @returns a transform node or null
  13393. */
  13394. getTransformNode(): Nullable<TransformNode>;
  13395. /** Gets or sets current position (in local space) */
  13396. position: Vector3;
  13397. /** Gets or sets current rotation (in local space) */
  13398. rotation: Vector3;
  13399. /** Gets or sets current rotation quaternion (in local space) */
  13400. rotationQuaternion: Quaternion;
  13401. /** Gets or sets current scaling (in local space) */
  13402. scaling: Vector3;
  13403. /**
  13404. * Gets the animation properties override
  13405. */
  13406. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13407. private _decompose;
  13408. private _compose;
  13409. /**
  13410. * Update the base and local matrices
  13411. * @param matrix defines the new base or local matrix
  13412. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13413. * @param updateLocalMatrix defines if the local matrix should be updated
  13414. */
  13415. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13416. /** @hidden */
  13417. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13418. /**
  13419. * Flag the bone as dirty (Forcing it to update everything)
  13420. */
  13421. markAsDirty(): void;
  13422. /** @hidden */
  13423. _markAsDirtyAndCompose(): void;
  13424. private _markAsDirtyAndDecompose;
  13425. /**
  13426. * Translate the bone in local or world space
  13427. * @param vec The amount to translate the bone
  13428. * @param space The space that the translation is in
  13429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13430. */
  13431. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13432. /**
  13433. * Set the postion of the bone in local or world space
  13434. * @param position The position to set the bone
  13435. * @param space The space that the position is in
  13436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13437. */
  13438. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13439. /**
  13440. * Set the absolute position of the bone (world space)
  13441. * @param position The position to set the bone
  13442. * @param mesh The mesh that this bone is attached to
  13443. */
  13444. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13445. /**
  13446. * Scale the bone on the x, y and z axes (in local space)
  13447. * @param x The amount to scale the bone on the x axis
  13448. * @param y The amount to scale the bone on the y axis
  13449. * @param z The amount to scale the bone on the z axis
  13450. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13451. */
  13452. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13453. /**
  13454. * Set the bone scaling in local space
  13455. * @param scale defines the scaling vector
  13456. */
  13457. setScale(scale: Vector3): void;
  13458. /**
  13459. * Gets the current scaling in local space
  13460. * @returns the current scaling vector
  13461. */
  13462. getScale(): Vector3;
  13463. /**
  13464. * Gets the current scaling in local space and stores it in a target vector
  13465. * @param result defines the target vector
  13466. */
  13467. getScaleToRef(result: Vector3): void;
  13468. /**
  13469. * Set the yaw, pitch, and roll of the bone in local or world space
  13470. * @param yaw The rotation of the bone on the y axis
  13471. * @param pitch The rotation of the bone on the x axis
  13472. * @param roll The rotation of the bone on the z axis
  13473. * @param space The space that the axes of rotation are in
  13474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13475. */
  13476. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13477. /**
  13478. * Add a rotation to the bone on an axis in local or world space
  13479. * @param axis The axis to rotate the bone on
  13480. * @param amount The amount to rotate the bone
  13481. * @param space The space that the axis is in
  13482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13483. */
  13484. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13485. /**
  13486. * Set the rotation of the bone to a particular axis angle in local or world space
  13487. * @param axis The axis to rotate the bone on
  13488. * @param angle The angle that the bone should be rotated to
  13489. * @param space The space that the axis is in
  13490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13491. */
  13492. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13493. /**
  13494. * Set the euler rotation of the bone in local of world space
  13495. * @param rotation The euler rotation that the bone should be set to
  13496. * @param space The space that the rotation is in
  13497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13498. */
  13499. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13500. /**
  13501. * Set the quaternion rotation of the bone in local of world space
  13502. * @param quat The quaternion rotation that the bone should be set to
  13503. * @param space The space that the rotation is in
  13504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13505. */
  13506. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13507. /**
  13508. * Set the rotation matrix of the bone in local of world space
  13509. * @param rotMat The rotation matrix that the bone should be set to
  13510. * @param space The space that the rotation is in
  13511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13512. */
  13513. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13514. private _rotateWithMatrix;
  13515. private _getNegativeRotationToRef;
  13516. /**
  13517. * Get the position of the bone in local or world space
  13518. * @param space The space that the returned position is in
  13519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13520. * @returns The position of the bone
  13521. */
  13522. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13523. /**
  13524. * Copy the position of the bone to a vector3 in local or world space
  13525. * @param space The space that the returned position is in
  13526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13527. * @param result The vector3 to copy the position to
  13528. */
  13529. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13530. /**
  13531. * Get the absolute position of the bone (world space)
  13532. * @param mesh The mesh that this bone is attached to
  13533. * @returns The absolute position of the bone
  13534. */
  13535. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13536. /**
  13537. * Copy the absolute position of the bone (world space) to the result param
  13538. * @param mesh The mesh that this bone is attached to
  13539. * @param result The vector3 to copy the absolute position to
  13540. */
  13541. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13542. /**
  13543. * Compute the absolute transforms of this bone and its children
  13544. */
  13545. computeAbsoluteTransforms(): void;
  13546. /**
  13547. * Get the world direction from an axis that is in the local space of the bone
  13548. * @param localAxis The local direction that is used to compute the world direction
  13549. * @param mesh The mesh that this bone is attached to
  13550. * @returns The world direction
  13551. */
  13552. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13553. /**
  13554. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13555. * @param localAxis The local direction that is used to compute the world direction
  13556. * @param mesh The mesh that this bone is attached to
  13557. * @param result The vector3 that the world direction will be copied to
  13558. */
  13559. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13560. /**
  13561. * Get the euler rotation of the bone in local or world space
  13562. * @param space The space that the rotation should be in
  13563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13564. * @returns The euler rotation
  13565. */
  13566. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13567. /**
  13568. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13569. * @param space The space that the rotation should be in
  13570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13571. * @param result The vector3 that the rotation should be copied to
  13572. */
  13573. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13574. /**
  13575. * Get the quaternion rotation of the bone in either local or world space
  13576. * @param space The space that the rotation should be in
  13577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13578. * @returns The quaternion rotation
  13579. */
  13580. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13581. /**
  13582. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13583. * @param space The space that the rotation should be in
  13584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13585. * @param result The quaternion that the rotation should be copied to
  13586. */
  13587. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13588. /**
  13589. * Get the rotation matrix of the bone in local or world space
  13590. * @param space The space that the rotation should be in
  13591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13592. * @returns The rotation matrix
  13593. */
  13594. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13595. /**
  13596. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13597. * @param space The space that the rotation should be in
  13598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13599. * @param result The quaternion that the rotation should be copied to
  13600. */
  13601. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13602. /**
  13603. * Get the world position of a point that is in the local space of the bone
  13604. * @param position The local position
  13605. * @param mesh The mesh that this bone is attached to
  13606. * @returns The world position
  13607. */
  13608. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13609. /**
  13610. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13611. * @param position The local position
  13612. * @param mesh The mesh that this bone is attached to
  13613. * @param result The vector3 that the world position should be copied to
  13614. */
  13615. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13616. /**
  13617. * Get the local position of a point that is in world space
  13618. * @param position The world position
  13619. * @param mesh The mesh that this bone is attached to
  13620. * @returns The local position
  13621. */
  13622. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13623. /**
  13624. * Get the local position of a point that is in world space and copy it to the result param
  13625. * @param position The world position
  13626. * @param mesh The mesh that this bone is attached to
  13627. * @param result The vector3 that the local position should be copied to
  13628. */
  13629. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13630. }
  13631. }
  13632. declare module BABYLON {
  13633. /**
  13634. * 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.
  13635. * @see https://doc.babylonjs.com/how_to/transformnode
  13636. */
  13637. export class TransformNode extends Node {
  13638. /**
  13639. * Object will not rotate to face the camera
  13640. */
  13641. static BILLBOARDMODE_NONE: number;
  13642. /**
  13643. * Object will rotate to face the camera but only on the x axis
  13644. */
  13645. static BILLBOARDMODE_X: number;
  13646. /**
  13647. * Object will rotate to face the camera but only on the y axis
  13648. */
  13649. static BILLBOARDMODE_Y: number;
  13650. /**
  13651. * Object will rotate to face the camera but only on the z axis
  13652. */
  13653. static BILLBOARDMODE_Z: number;
  13654. /**
  13655. * Object will rotate to face the camera
  13656. */
  13657. static BILLBOARDMODE_ALL: number;
  13658. /**
  13659. * Object will rotate to face the camera's position instead of orientation
  13660. */
  13661. static BILLBOARDMODE_USE_POSITION: number;
  13662. private _forward;
  13663. private _forwardInverted;
  13664. private _up;
  13665. private _right;
  13666. private _rightInverted;
  13667. private _position;
  13668. private _rotation;
  13669. private _rotationQuaternion;
  13670. protected _scaling: Vector3;
  13671. protected _isDirty: boolean;
  13672. private _transformToBoneReferal;
  13673. private _isAbsoluteSynced;
  13674. private _billboardMode;
  13675. /**
  13676. * Gets or sets the billboard mode. Default is 0.
  13677. *
  13678. * | Value | Type | Description |
  13679. * | --- | --- | --- |
  13680. * | 0 | BILLBOARDMODE_NONE | |
  13681. * | 1 | BILLBOARDMODE_X | |
  13682. * | 2 | BILLBOARDMODE_Y | |
  13683. * | 4 | BILLBOARDMODE_Z | |
  13684. * | 7 | BILLBOARDMODE_ALL | |
  13685. *
  13686. */
  13687. billboardMode: number;
  13688. private _preserveParentRotationForBillboard;
  13689. /**
  13690. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13691. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13692. */
  13693. preserveParentRotationForBillboard: boolean;
  13694. /**
  13695. * 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
  13696. */
  13697. scalingDeterminant: number;
  13698. private _infiniteDistance;
  13699. /**
  13700. * Gets or sets the distance of the object to max, often used by skybox
  13701. */
  13702. infiniteDistance: boolean;
  13703. /**
  13704. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13705. * By default the system will update normals to compensate
  13706. */
  13707. ignoreNonUniformScaling: boolean;
  13708. /**
  13709. * 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
  13710. */
  13711. reIntegrateRotationIntoRotationQuaternion: boolean;
  13712. /** @hidden */
  13713. _poseMatrix: Nullable<Matrix>;
  13714. /** @hidden */
  13715. _localMatrix: Matrix;
  13716. private _usePivotMatrix;
  13717. private _absolutePosition;
  13718. private _absoluteScaling;
  13719. private _absoluteRotationQuaternion;
  13720. private _pivotMatrix;
  13721. private _pivotMatrixInverse;
  13722. protected _postMultiplyPivotMatrix: boolean;
  13723. protected _isWorldMatrixFrozen: boolean;
  13724. /** @hidden */
  13725. _indexInSceneTransformNodesArray: number;
  13726. /**
  13727. * An event triggered after the world matrix is updated
  13728. */
  13729. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13730. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13731. /**
  13732. * Gets a string identifying the name of the class
  13733. * @returns "TransformNode" string
  13734. */
  13735. getClassName(): string;
  13736. /**
  13737. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13738. */
  13739. position: Vector3;
  13740. /**
  13741. * 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)).
  13742. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13743. */
  13744. rotation: Vector3;
  13745. /**
  13746. * 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)).
  13747. */
  13748. scaling: Vector3;
  13749. /**
  13750. * 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).
  13751. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13752. */
  13753. rotationQuaternion: Nullable<Quaternion>;
  13754. /**
  13755. * The forward direction of that transform in world space.
  13756. */
  13757. readonly forward: Vector3;
  13758. /**
  13759. * The up direction of that transform in world space.
  13760. */
  13761. readonly up: Vector3;
  13762. /**
  13763. * The right direction of that transform in world space.
  13764. */
  13765. readonly right: Vector3;
  13766. /**
  13767. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13768. * @param matrix the matrix to copy the pose from
  13769. * @returns this TransformNode.
  13770. */
  13771. updatePoseMatrix(matrix: Matrix): TransformNode;
  13772. /**
  13773. * Returns the mesh Pose matrix.
  13774. * @returns the pose matrix
  13775. */
  13776. getPoseMatrix(): Matrix;
  13777. /** @hidden */
  13778. _isSynchronized(): boolean;
  13779. /** @hidden */
  13780. _initCache(): void;
  13781. /**
  13782. * Flag the transform node as dirty (Forcing it to update everything)
  13783. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13784. * @returns this transform node
  13785. */
  13786. markAsDirty(property: string): TransformNode;
  13787. /**
  13788. * Returns the current mesh absolute position.
  13789. * Returns a Vector3.
  13790. */
  13791. readonly absolutePosition: Vector3;
  13792. /**
  13793. * Returns the current mesh absolute scaling.
  13794. * Returns a Vector3.
  13795. */
  13796. readonly absoluteScaling: Vector3;
  13797. /**
  13798. * Returns the current mesh absolute rotation.
  13799. * Returns a Quaternion.
  13800. */
  13801. readonly absoluteRotationQuaternion: Quaternion;
  13802. /**
  13803. * Sets a new matrix to apply before all other transformation
  13804. * @param matrix defines the transform matrix
  13805. * @returns the current TransformNode
  13806. */
  13807. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13808. /**
  13809. * Sets a new pivot matrix to the current node
  13810. * @param matrix defines the new pivot matrix to use
  13811. * @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
  13812. * @returns the current TransformNode
  13813. */
  13814. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13815. /**
  13816. * Returns the mesh pivot matrix.
  13817. * Default : Identity.
  13818. * @returns the matrix
  13819. */
  13820. getPivotMatrix(): Matrix;
  13821. /**
  13822. * Prevents the World matrix to be computed any longer.
  13823. * @returns the TransformNode.
  13824. */
  13825. freezeWorldMatrix(): TransformNode;
  13826. /**
  13827. * Allows back the World matrix computation.
  13828. * @returns the TransformNode.
  13829. */
  13830. unfreezeWorldMatrix(): this;
  13831. /**
  13832. * True if the World matrix has been frozen.
  13833. */
  13834. readonly isWorldMatrixFrozen: boolean;
  13835. /**
  13836. * Retuns the mesh absolute position in the World.
  13837. * @returns a Vector3.
  13838. */
  13839. getAbsolutePosition(): Vector3;
  13840. /**
  13841. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13842. * @param absolutePosition the absolute position to set
  13843. * @returns the TransformNode.
  13844. */
  13845. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13846. /**
  13847. * Sets the mesh position in its local space.
  13848. * @param vector3 the position to set in localspace
  13849. * @returns the TransformNode.
  13850. */
  13851. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13852. /**
  13853. * Returns the mesh position in the local space from the current World matrix values.
  13854. * @returns a new Vector3.
  13855. */
  13856. getPositionExpressedInLocalSpace(): Vector3;
  13857. /**
  13858. * Translates the mesh along the passed Vector3 in its local space.
  13859. * @param vector3 the distance to translate in localspace
  13860. * @returns the TransformNode.
  13861. */
  13862. locallyTranslate(vector3: Vector3): TransformNode;
  13863. private static _lookAtVectorCache;
  13864. /**
  13865. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13866. * @param targetPoint the position (must be in same space as current mesh) to look at
  13867. * @param yawCor optional yaw (y-axis) correction in radians
  13868. * @param pitchCor optional pitch (x-axis) correction in radians
  13869. * @param rollCor optional roll (z-axis) correction in radians
  13870. * @param space the choosen space of the target
  13871. * @returns the TransformNode.
  13872. */
  13873. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13874. /**
  13875. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13876. * This Vector3 is expressed in the World space.
  13877. * @param localAxis axis to rotate
  13878. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13879. */
  13880. getDirection(localAxis: Vector3): Vector3;
  13881. /**
  13882. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13883. * localAxis is expressed in the mesh local space.
  13884. * result is computed in the Wordl space from the mesh World matrix.
  13885. * @param localAxis axis to rotate
  13886. * @param result the resulting transformnode
  13887. * @returns this TransformNode.
  13888. */
  13889. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13890. /**
  13891. * Sets this transform node rotation to the given local axis.
  13892. * @param localAxis the axis in local space
  13893. * @param yawCor optional yaw (y-axis) correction in radians
  13894. * @param pitchCor optional pitch (x-axis) correction in radians
  13895. * @param rollCor optional roll (z-axis) correction in radians
  13896. * @returns this TransformNode
  13897. */
  13898. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13899. /**
  13900. * Sets a new pivot point to the current node
  13901. * @param point defines the new pivot point to use
  13902. * @param space defines if the point is in world or local space (local by default)
  13903. * @returns the current TransformNode
  13904. */
  13905. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13906. /**
  13907. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13908. * @returns the pivot point
  13909. */
  13910. getPivotPoint(): Vector3;
  13911. /**
  13912. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13913. * @param result the vector3 to store the result
  13914. * @returns this TransformNode.
  13915. */
  13916. getPivotPointToRef(result: Vector3): TransformNode;
  13917. /**
  13918. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13919. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13920. */
  13921. getAbsolutePivotPoint(): Vector3;
  13922. /**
  13923. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13924. * @param result vector3 to store the result
  13925. * @returns this TransformNode.
  13926. */
  13927. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13928. /**
  13929. * Defines the passed node as the parent of the current node.
  13930. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13931. * @see https://doc.babylonjs.com/how_to/parenting
  13932. * @param node the node ot set as the parent
  13933. * @returns this TransformNode.
  13934. */
  13935. setParent(node: Nullable<Node>): TransformNode;
  13936. private _nonUniformScaling;
  13937. /**
  13938. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13939. */
  13940. readonly nonUniformScaling: boolean;
  13941. /** @hidden */
  13942. _updateNonUniformScalingState(value: boolean): boolean;
  13943. /**
  13944. * Attach the current TransformNode to another TransformNode associated with a bone
  13945. * @param bone Bone affecting the TransformNode
  13946. * @param affectedTransformNode TransformNode associated with the bone
  13947. * @returns this object
  13948. */
  13949. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13950. /**
  13951. * Detach the transform node if its associated with a bone
  13952. * @returns this object
  13953. */
  13954. detachFromBone(): TransformNode;
  13955. private static _rotationAxisCache;
  13956. /**
  13957. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13958. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13959. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13960. * The passed axis is also normalized.
  13961. * @param axis the axis to rotate around
  13962. * @param amount the amount to rotate in radians
  13963. * @param space Space to rotate in (Default: local)
  13964. * @returns the TransformNode.
  13965. */
  13966. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13967. /**
  13968. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13969. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13970. * The passed axis is also normalized. .
  13971. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13972. * @param point the point to rotate around
  13973. * @param axis the axis to rotate around
  13974. * @param amount the amount to rotate in radians
  13975. * @returns the TransformNode
  13976. */
  13977. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13978. /**
  13979. * Translates the mesh along the axis vector for the passed distance in the given space.
  13980. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13981. * @param axis the axis to translate in
  13982. * @param distance the distance to translate
  13983. * @param space Space to rotate in (Default: local)
  13984. * @returns the TransformNode.
  13985. */
  13986. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13987. /**
  13988. * Adds a rotation step to the mesh current rotation.
  13989. * x, y, z are Euler angles expressed in radians.
  13990. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13991. * This means this rotation is made in the mesh local space only.
  13992. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13993. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13994. * ```javascript
  13995. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13996. * ```
  13997. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13998. * 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.
  13999. * @param x Rotation to add
  14000. * @param y Rotation to add
  14001. * @param z Rotation to add
  14002. * @returns the TransformNode.
  14003. */
  14004. addRotation(x: number, y: number, z: number): TransformNode;
  14005. /**
  14006. * @hidden
  14007. */
  14008. protected _getEffectiveParent(): Nullable<Node>;
  14009. /**
  14010. * Computes the world matrix of the node
  14011. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14012. * @returns the world matrix
  14013. */
  14014. computeWorldMatrix(force?: boolean): Matrix;
  14015. protected _afterComputeWorldMatrix(): void;
  14016. /**
  14017. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14018. * @param func callback function to add
  14019. *
  14020. * @returns the TransformNode.
  14021. */
  14022. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14023. /**
  14024. * Removes a registered callback function.
  14025. * @param func callback function to remove
  14026. * @returns the TransformNode.
  14027. */
  14028. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14029. /**
  14030. * Gets the position of the current mesh in camera space
  14031. * @param camera defines the camera to use
  14032. * @returns a position
  14033. */
  14034. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14035. /**
  14036. * Returns the distance from the mesh to the active camera
  14037. * @param camera defines the camera to use
  14038. * @returns the distance
  14039. */
  14040. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14041. /**
  14042. * Clone the current transform node
  14043. * @param name Name of the new clone
  14044. * @param newParent New parent for the clone
  14045. * @param doNotCloneChildren Do not clone children hierarchy
  14046. * @returns the new transform node
  14047. */
  14048. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14049. /**
  14050. * Serializes the objects information.
  14051. * @param currentSerializationObject defines the object to serialize in
  14052. * @returns the serialized object
  14053. */
  14054. serialize(currentSerializationObject?: any): any;
  14055. /**
  14056. * Returns a new TransformNode object parsed from the source provided.
  14057. * @param parsedTransformNode is the source.
  14058. * @param scene the scne the object belongs to
  14059. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14060. * @returns a new TransformNode object parsed from the source provided.
  14061. */
  14062. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14063. /**
  14064. * Get all child-transformNodes of this node
  14065. * @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
  14066. * @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
  14067. * @returns an array of TransformNode
  14068. */
  14069. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14070. /**
  14071. * Releases resources associated with this transform node.
  14072. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14073. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14074. */
  14075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14076. /**
  14077. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14078. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14079. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14080. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14081. * @returns the current mesh
  14082. */
  14083. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14084. private _syncAbsoluteScalingAndRotation;
  14085. }
  14086. }
  14087. declare module BABYLON {
  14088. /**
  14089. * Defines the types of pose enabled controllers that are supported
  14090. */
  14091. export enum PoseEnabledControllerType {
  14092. /**
  14093. * HTC Vive
  14094. */
  14095. VIVE = 0,
  14096. /**
  14097. * Oculus Rift
  14098. */
  14099. OCULUS = 1,
  14100. /**
  14101. * Windows mixed reality
  14102. */
  14103. WINDOWS = 2,
  14104. /**
  14105. * Samsung gear VR
  14106. */
  14107. GEAR_VR = 3,
  14108. /**
  14109. * Google Daydream
  14110. */
  14111. DAYDREAM = 4,
  14112. /**
  14113. * Generic
  14114. */
  14115. GENERIC = 5
  14116. }
  14117. /**
  14118. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14119. */
  14120. export interface MutableGamepadButton {
  14121. /**
  14122. * Value of the button/trigger
  14123. */
  14124. value: number;
  14125. /**
  14126. * If the button/trigger is currently touched
  14127. */
  14128. touched: boolean;
  14129. /**
  14130. * If the button/trigger is currently pressed
  14131. */
  14132. pressed: boolean;
  14133. }
  14134. /**
  14135. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14136. * @hidden
  14137. */
  14138. export interface ExtendedGamepadButton extends GamepadButton {
  14139. /**
  14140. * If the button/trigger is currently pressed
  14141. */
  14142. readonly pressed: boolean;
  14143. /**
  14144. * If the button/trigger is currently touched
  14145. */
  14146. readonly touched: boolean;
  14147. /**
  14148. * Value of the button/trigger
  14149. */
  14150. readonly value: number;
  14151. }
  14152. /** @hidden */
  14153. export interface _GamePadFactory {
  14154. /**
  14155. * Returns wether or not the current gamepad can be created for this type of controller.
  14156. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14157. * @returns true if it can be created, otherwise false
  14158. */
  14159. canCreate(gamepadInfo: any): boolean;
  14160. /**
  14161. * Creates a new instance of the Gamepad.
  14162. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14163. * @returns the new gamepad instance
  14164. */
  14165. create(gamepadInfo: any): Gamepad;
  14166. }
  14167. /**
  14168. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14169. */
  14170. export class PoseEnabledControllerHelper {
  14171. /** @hidden */
  14172. static _ControllerFactories: _GamePadFactory[];
  14173. /** @hidden */
  14174. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14175. /**
  14176. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14177. * @param vrGamepad the gamepad to initialized
  14178. * @returns a vr controller of the type the gamepad identified as
  14179. */
  14180. static InitiateController(vrGamepad: any): Gamepad;
  14181. }
  14182. /**
  14183. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14184. */
  14185. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14186. /**
  14187. * If the controller is used in a webXR session
  14188. */
  14189. isXR: boolean;
  14190. private _deviceRoomPosition;
  14191. private _deviceRoomRotationQuaternion;
  14192. /**
  14193. * The device position in babylon space
  14194. */
  14195. devicePosition: Vector3;
  14196. /**
  14197. * The device rotation in babylon space
  14198. */
  14199. deviceRotationQuaternion: Quaternion;
  14200. /**
  14201. * The scale factor of the device in babylon space
  14202. */
  14203. deviceScaleFactor: number;
  14204. /**
  14205. * (Likely devicePosition should be used instead) The device position in its room space
  14206. */
  14207. position: Vector3;
  14208. /**
  14209. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14210. */
  14211. rotationQuaternion: Quaternion;
  14212. /**
  14213. * The type of controller (Eg. Windows mixed reality)
  14214. */
  14215. controllerType: PoseEnabledControllerType;
  14216. protected _calculatedPosition: Vector3;
  14217. private _calculatedRotation;
  14218. /**
  14219. * The raw pose from the device
  14220. */
  14221. rawPose: DevicePose;
  14222. private _trackPosition;
  14223. private _maxRotationDistFromHeadset;
  14224. private _draggedRoomRotation;
  14225. /**
  14226. * @hidden
  14227. */
  14228. _disableTrackPosition(fixedPosition: Vector3): void;
  14229. /**
  14230. * Internal, the mesh attached to the controller
  14231. * @hidden
  14232. */
  14233. _mesh: Nullable<AbstractMesh>;
  14234. private _poseControlledCamera;
  14235. private _leftHandSystemQuaternion;
  14236. /**
  14237. * Internal, matrix used to convert room space to babylon space
  14238. * @hidden
  14239. */
  14240. _deviceToWorld: Matrix;
  14241. /**
  14242. * Node to be used when casting a ray from the controller
  14243. * @hidden
  14244. */
  14245. _pointingPoseNode: Nullable<TransformNode>;
  14246. /**
  14247. * Name of the child mesh that can be used to cast a ray from the controller
  14248. */
  14249. static readonly POINTING_POSE: string;
  14250. /**
  14251. * Creates a new PoseEnabledController from a gamepad
  14252. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14253. */
  14254. constructor(browserGamepad: any);
  14255. private _workingMatrix;
  14256. /**
  14257. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14258. */
  14259. update(): void;
  14260. /**
  14261. * Updates only the pose device and mesh without doing any button event checking
  14262. */
  14263. protected _updatePoseAndMesh(): void;
  14264. /**
  14265. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14266. * @param poseData raw pose fromthe device
  14267. */
  14268. updateFromDevice(poseData: DevicePose): void;
  14269. /**
  14270. * @hidden
  14271. */
  14272. _meshAttachedObservable: Observable<AbstractMesh>;
  14273. /**
  14274. * Attaches a mesh to the controller
  14275. * @param mesh the mesh to be attached
  14276. */
  14277. attachToMesh(mesh: AbstractMesh): void;
  14278. /**
  14279. * Attaches the controllers mesh to a camera
  14280. * @param camera the camera the mesh should be attached to
  14281. */
  14282. attachToPoseControlledCamera(camera: TargetCamera): void;
  14283. /**
  14284. * Disposes of the controller
  14285. */
  14286. dispose(): void;
  14287. /**
  14288. * The mesh that is attached to the controller
  14289. */
  14290. readonly mesh: Nullable<AbstractMesh>;
  14291. /**
  14292. * Gets the ray of the controller in the direction the controller is pointing
  14293. * @param length the length the resulting ray should be
  14294. * @returns a ray in the direction the controller is pointing
  14295. */
  14296. getForwardRay(length?: number): Ray;
  14297. }
  14298. }
  14299. declare module BABYLON {
  14300. /**
  14301. * Defines the WebVRController object that represents controllers tracked in 3D space
  14302. */
  14303. export abstract class WebVRController extends PoseEnabledController {
  14304. /**
  14305. * Internal, the default controller model for the controller
  14306. */
  14307. protected _defaultModel: AbstractMesh;
  14308. /**
  14309. * Fired when the trigger state has changed
  14310. */
  14311. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14312. /**
  14313. * Fired when the main button state has changed
  14314. */
  14315. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14316. /**
  14317. * Fired when the secondary button state has changed
  14318. */
  14319. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14320. /**
  14321. * Fired when the pad state has changed
  14322. */
  14323. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14324. /**
  14325. * Fired when controllers stick values have changed
  14326. */
  14327. onPadValuesChangedObservable: Observable<StickValues>;
  14328. /**
  14329. * Array of button availible on the controller
  14330. */
  14331. protected _buttons: Array<MutableGamepadButton>;
  14332. private _onButtonStateChange;
  14333. /**
  14334. * Fired when a controller button's state has changed
  14335. * @param callback the callback containing the button that was modified
  14336. */
  14337. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14338. /**
  14339. * X and Y axis corresponding to the controllers joystick
  14340. */
  14341. pad: StickValues;
  14342. /**
  14343. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14344. */
  14345. hand: string;
  14346. /**
  14347. * The default controller model for the controller
  14348. */
  14349. readonly defaultModel: AbstractMesh;
  14350. /**
  14351. * Creates a new WebVRController from a gamepad
  14352. * @param vrGamepad the gamepad that the WebVRController should be created from
  14353. */
  14354. constructor(vrGamepad: any);
  14355. /**
  14356. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14357. */
  14358. update(): void;
  14359. /**
  14360. * Function to be called when a button is modified
  14361. */
  14362. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14363. /**
  14364. * Loads a mesh and attaches it to the controller
  14365. * @param scene the scene the mesh should be added to
  14366. * @param meshLoaded callback for when the mesh has been loaded
  14367. */
  14368. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14369. private _setButtonValue;
  14370. private _changes;
  14371. private _checkChanges;
  14372. /**
  14373. * Disposes of th webVRCOntroller
  14374. */
  14375. dispose(): void;
  14376. }
  14377. }
  14378. declare module BABYLON {
  14379. /**
  14380. * The HemisphericLight simulates the ambient environment light,
  14381. * so the passed direction is the light reflection direction, not the incoming direction.
  14382. */
  14383. export class HemisphericLight extends Light {
  14384. /**
  14385. * The groundColor is the light in the opposite direction to the one specified during creation.
  14386. * 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.
  14387. */
  14388. groundColor: Color3;
  14389. /**
  14390. * The light reflection direction, not the incoming direction.
  14391. */
  14392. direction: Vector3;
  14393. /**
  14394. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14395. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14396. * The HemisphericLight can't cast shadows.
  14397. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14398. * @param name The friendly name of the light
  14399. * @param direction The direction of the light reflection
  14400. * @param scene The scene the light belongs to
  14401. */
  14402. constructor(name: string, direction: Vector3, scene: Scene);
  14403. protected _buildUniformLayout(): void;
  14404. /**
  14405. * Returns the string "HemisphericLight".
  14406. * @return The class name
  14407. */
  14408. getClassName(): string;
  14409. /**
  14410. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14411. * Returns the updated direction.
  14412. * @param target The target the direction should point to
  14413. * @return The computed direction
  14414. */
  14415. setDirectionToTarget(target: Vector3): Vector3;
  14416. /**
  14417. * Returns the shadow generator associated to the light.
  14418. * @returns Always null for hemispheric lights because it does not support shadows.
  14419. */
  14420. getShadowGenerator(): Nullable<IShadowGenerator>;
  14421. /**
  14422. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14423. * @param effect The effect to update
  14424. * @param lightIndex The index of the light in the effect to update
  14425. * @returns The hemispheric light
  14426. */
  14427. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14428. /**
  14429. * Computes the world matrix of the node
  14430. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14431. * @param useWasUpdatedFlag defines a reserved property
  14432. * @returns the world matrix
  14433. */
  14434. computeWorldMatrix(): Matrix;
  14435. /**
  14436. * Returns the integer 3.
  14437. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14438. */
  14439. getTypeID(): number;
  14440. /**
  14441. * Prepares the list of defines specific to the light type.
  14442. * @param defines the list of defines
  14443. * @param lightIndex defines the index of the light for the effect
  14444. */
  14445. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14446. }
  14447. }
  14448. declare module BABYLON {
  14449. /** @hidden */
  14450. export var vrMultiviewToSingleviewPixelShader: {
  14451. name: string;
  14452. shader: string;
  14453. };
  14454. }
  14455. declare module BABYLON {
  14456. /**
  14457. * Renders to multiple views with a single draw call
  14458. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14459. */
  14460. export class MultiviewRenderTarget extends RenderTargetTexture {
  14461. /**
  14462. * Creates a multiview render target
  14463. * @param scene scene used with the render target
  14464. * @param size the size of the render target (used for each view)
  14465. */
  14466. constructor(scene: Scene, size?: number | {
  14467. width: number;
  14468. height: number;
  14469. } | {
  14470. ratio: number;
  14471. });
  14472. /**
  14473. * @hidden
  14474. * @param faceIndex the face index, if its a cube texture
  14475. */
  14476. _bindFrameBuffer(faceIndex?: number): void;
  14477. /**
  14478. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14479. * @returns the view count
  14480. */
  14481. getViewCount(): number;
  14482. }
  14483. }
  14484. declare module BABYLON {
  14485. /**
  14486. * Reprasents a camera frustum
  14487. */
  14488. export class Frustum {
  14489. /**
  14490. * Gets the planes representing the frustum
  14491. * @param transform matrix to be applied to the returned planes
  14492. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14493. */
  14494. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14495. /**
  14496. * Gets the near frustum plane transformed by the transform matrix
  14497. * @param transform transformation matrix to be applied to the resulting frustum plane
  14498. * @param frustumPlane the resuling frustum plane
  14499. */
  14500. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14501. /**
  14502. * Gets the far frustum plane transformed by the transform matrix
  14503. * @param transform transformation matrix to be applied to the resulting frustum plane
  14504. * @param frustumPlane the resuling frustum plane
  14505. */
  14506. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14507. /**
  14508. * Gets the left frustum plane transformed by the transform matrix
  14509. * @param transform transformation matrix to be applied to the resulting frustum plane
  14510. * @param frustumPlane the resuling frustum plane
  14511. */
  14512. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14513. /**
  14514. * Gets the right frustum plane transformed by the transform matrix
  14515. * @param transform transformation matrix to be applied to the resulting frustum plane
  14516. * @param frustumPlane the resuling frustum plane
  14517. */
  14518. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14519. /**
  14520. * Gets the top frustum plane transformed by the transform matrix
  14521. * @param transform transformation matrix to be applied to the resulting frustum plane
  14522. * @param frustumPlane the resuling frustum plane
  14523. */
  14524. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14525. /**
  14526. * Gets the bottom frustum plane transformed by the transform matrix
  14527. * @param transform transformation matrix to be applied to the resulting frustum plane
  14528. * @param frustumPlane the resuling frustum plane
  14529. */
  14530. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14531. /**
  14532. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14533. * @param transform transformation matrix to be applied to the resulting frustum planes
  14534. * @param frustumPlanes the resuling frustum planes
  14535. */
  14536. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14537. }
  14538. }
  14539. declare module BABYLON {
  14540. interface Engine {
  14541. /**
  14542. * Creates a new multiview render target
  14543. * @param width defines the width of the texture
  14544. * @param height defines the height of the texture
  14545. * @returns the created multiview texture
  14546. */
  14547. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14548. /**
  14549. * Binds a multiview framebuffer to be drawn to
  14550. * @param multiviewTexture texture to bind
  14551. */
  14552. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14553. }
  14554. interface Camera {
  14555. /**
  14556. * @hidden
  14557. * 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)
  14558. */
  14559. _useMultiviewToSingleView: boolean;
  14560. /**
  14561. * @hidden
  14562. * 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)
  14563. */
  14564. _multiviewTexture: Nullable<RenderTargetTexture>;
  14565. /**
  14566. * @hidden
  14567. * ensures the multiview texture of the camera exists and has the specified width/height
  14568. * @param width height to set on the multiview texture
  14569. * @param height width to set on the multiview texture
  14570. */
  14571. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14572. }
  14573. interface Scene {
  14574. /** @hidden */
  14575. _transformMatrixR: Matrix;
  14576. /** @hidden */
  14577. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14578. /** @hidden */
  14579. _createMultiviewUbo(): void;
  14580. /** @hidden */
  14581. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14582. /** @hidden */
  14583. _renderMultiviewToSingleView(camera: Camera): void;
  14584. }
  14585. }
  14586. declare module BABYLON {
  14587. /**
  14588. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14589. * This will not be used for webXR as it supports displaying texture arrays directly
  14590. */
  14591. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14592. /**
  14593. * Initializes a VRMultiviewToSingleview
  14594. * @param name name of the post process
  14595. * @param camera camera to be applied to
  14596. * @param scaleFactor scaling factor to the size of the output texture
  14597. */
  14598. constructor(name: string, camera: Camera, scaleFactor: number);
  14599. }
  14600. }
  14601. declare module BABYLON {
  14602. interface Engine {
  14603. /** @hidden */
  14604. _vrDisplay: any;
  14605. /** @hidden */
  14606. _vrSupported: boolean;
  14607. /** @hidden */
  14608. _oldSize: Size;
  14609. /** @hidden */
  14610. _oldHardwareScaleFactor: number;
  14611. /** @hidden */
  14612. _vrExclusivePointerMode: boolean;
  14613. /** @hidden */
  14614. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14615. /** @hidden */
  14616. _onVRDisplayPointerRestricted: () => void;
  14617. /** @hidden */
  14618. _onVRDisplayPointerUnrestricted: () => void;
  14619. /** @hidden */
  14620. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14621. /** @hidden */
  14622. _onVrDisplayDisconnect: Nullable<() => void>;
  14623. /** @hidden */
  14624. _onVrDisplayPresentChange: Nullable<() => void>;
  14625. /**
  14626. * Observable signaled when VR display mode changes
  14627. */
  14628. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14629. /**
  14630. * Observable signaled when VR request present is complete
  14631. */
  14632. onVRRequestPresentComplete: Observable<boolean>;
  14633. /**
  14634. * Observable signaled when VR request present starts
  14635. */
  14636. onVRRequestPresentStart: Observable<Engine>;
  14637. /**
  14638. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14639. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14640. */
  14641. isInVRExclusivePointerMode: boolean;
  14642. /**
  14643. * Gets a boolean indicating if a webVR device was detected
  14644. * @returns true if a webVR device was detected
  14645. */
  14646. isVRDevicePresent(): boolean;
  14647. /**
  14648. * Gets the current webVR device
  14649. * @returns the current webVR device (or null)
  14650. */
  14651. getVRDevice(): any;
  14652. /**
  14653. * Initializes a webVR display and starts listening to display change events
  14654. * The onVRDisplayChangedObservable will be notified upon these changes
  14655. * @returns A promise containing a VRDisplay and if vr is supported
  14656. */
  14657. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14658. /** @hidden */
  14659. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14660. /**
  14661. * Call this function to switch to webVR mode
  14662. * Will do nothing if webVR is not supported or if there is no webVR device
  14663. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14664. */
  14665. enableVR(): void;
  14666. /** @hidden */
  14667. _onVRFullScreenTriggered(): void;
  14668. }
  14669. }
  14670. declare module BABYLON {
  14671. /**
  14672. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14673. * IMPORTANT!! The data is right-hand data.
  14674. * @export
  14675. * @interface DevicePose
  14676. */
  14677. export interface DevicePose {
  14678. /**
  14679. * The position of the device, values in array are [x,y,z].
  14680. */
  14681. readonly position: Nullable<Float32Array>;
  14682. /**
  14683. * The linearVelocity of the device, values in array are [x,y,z].
  14684. */
  14685. readonly linearVelocity: Nullable<Float32Array>;
  14686. /**
  14687. * The linearAcceleration of the device, values in array are [x,y,z].
  14688. */
  14689. readonly linearAcceleration: Nullable<Float32Array>;
  14690. /**
  14691. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14692. */
  14693. readonly orientation: Nullable<Float32Array>;
  14694. /**
  14695. * The angularVelocity of the device, values in array are [x,y,z].
  14696. */
  14697. readonly angularVelocity: Nullable<Float32Array>;
  14698. /**
  14699. * The angularAcceleration of the device, values in array are [x,y,z].
  14700. */
  14701. readonly angularAcceleration: Nullable<Float32Array>;
  14702. }
  14703. /**
  14704. * Interface representing a pose controlled object in Babylon.
  14705. * A pose controlled object has both regular pose values as well as pose values
  14706. * from an external device such as a VR head mounted display
  14707. */
  14708. export interface PoseControlled {
  14709. /**
  14710. * The position of the object in babylon space.
  14711. */
  14712. position: Vector3;
  14713. /**
  14714. * The rotation quaternion of the object in babylon space.
  14715. */
  14716. rotationQuaternion: Quaternion;
  14717. /**
  14718. * The position of the device in babylon space.
  14719. */
  14720. devicePosition?: Vector3;
  14721. /**
  14722. * The rotation quaternion of the device in babylon space.
  14723. */
  14724. deviceRotationQuaternion: Quaternion;
  14725. /**
  14726. * The raw pose coming from the device.
  14727. */
  14728. rawPose: Nullable<DevicePose>;
  14729. /**
  14730. * The scale of the device to be used when translating from device space to babylon space.
  14731. */
  14732. deviceScaleFactor: number;
  14733. /**
  14734. * Updates the poseControlled values based on the input device pose.
  14735. * @param poseData the pose data to update the object with
  14736. */
  14737. updateFromDevice(poseData: DevicePose): void;
  14738. }
  14739. /**
  14740. * Set of options to customize the webVRCamera
  14741. */
  14742. export interface WebVROptions {
  14743. /**
  14744. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14745. */
  14746. trackPosition?: boolean;
  14747. /**
  14748. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14749. */
  14750. positionScale?: number;
  14751. /**
  14752. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14753. */
  14754. displayName?: string;
  14755. /**
  14756. * Should the native controller meshes be initialized. (default: true)
  14757. */
  14758. controllerMeshes?: boolean;
  14759. /**
  14760. * Creating a default HemiLight only on controllers. (default: true)
  14761. */
  14762. defaultLightingOnControllers?: boolean;
  14763. /**
  14764. * If you don't want to use the default VR button of the helper. (default: false)
  14765. */
  14766. useCustomVRButton?: boolean;
  14767. /**
  14768. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14769. */
  14770. customVRButton?: HTMLButtonElement;
  14771. /**
  14772. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14773. */
  14774. rayLength?: number;
  14775. /**
  14776. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14777. */
  14778. defaultHeight?: number;
  14779. /**
  14780. * If multiview should be used if availible (default: false)
  14781. */
  14782. useMultiview?: boolean;
  14783. }
  14784. /**
  14785. * This represents a WebVR camera.
  14786. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14787. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14788. */
  14789. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14790. private webVROptions;
  14791. /**
  14792. * @hidden
  14793. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14794. */
  14795. _vrDevice: any;
  14796. /**
  14797. * The rawPose of the vrDevice.
  14798. */
  14799. rawPose: Nullable<DevicePose>;
  14800. private _onVREnabled;
  14801. private _specsVersion;
  14802. private _attached;
  14803. private _frameData;
  14804. protected _descendants: Array<Node>;
  14805. private _deviceRoomPosition;
  14806. /** @hidden */
  14807. _deviceRoomRotationQuaternion: Quaternion;
  14808. private _standingMatrix;
  14809. /**
  14810. * Represents device position in babylon space.
  14811. */
  14812. devicePosition: Vector3;
  14813. /**
  14814. * Represents device rotation in babylon space.
  14815. */
  14816. deviceRotationQuaternion: Quaternion;
  14817. /**
  14818. * The scale of the device to be used when translating from device space to babylon space.
  14819. */
  14820. deviceScaleFactor: number;
  14821. private _deviceToWorld;
  14822. private _worldToDevice;
  14823. /**
  14824. * References to the webVR controllers for the vrDevice.
  14825. */
  14826. controllers: Array<WebVRController>;
  14827. /**
  14828. * Emits an event when a controller is attached.
  14829. */
  14830. onControllersAttachedObservable: Observable<WebVRController[]>;
  14831. /**
  14832. * Emits an event when a controller's mesh has been loaded;
  14833. */
  14834. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14835. /**
  14836. * Emits an event when the HMD's pose has been updated.
  14837. */
  14838. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14839. private _poseSet;
  14840. /**
  14841. * If the rig cameras be used as parent instead of this camera.
  14842. */
  14843. rigParenting: boolean;
  14844. private _lightOnControllers;
  14845. private _defaultHeight?;
  14846. /**
  14847. * Instantiates a WebVRFreeCamera.
  14848. * @param name The name of the WebVRFreeCamera
  14849. * @param position The starting anchor position for the camera
  14850. * @param scene The scene the camera belongs to
  14851. * @param webVROptions a set of customizable options for the webVRCamera
  14852. */
  14853. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14854. /**
  14855. * Gets the device distance from the ground in meters.
  14856. * @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.
  14857. */
  14858. deviceDistanceToRoomGround(): number;
  14859. /**
  14860. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14861. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14862. */
  14863. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14864. /**
  14865. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14866. * @returns A promise with a boolean set to if the standing matrix is supported.
  14867. */
  14868. useStandingMatrixAsync(): Promise<boolean>;
  14869. /**
  14870. * Disposes the camera
  14871. */
  14872. dispose(): void;
  14873. /**
  14874. * Gets a vrController by name.
  14875. * @param name The name of the controller to retreive
  14876. * @returns the controller matching the name specified or null if not found
  14877. */
  14878. getControllerByName(name: string): Nullable<WebVRController>;
  14879. private _leftController;
  14880. /**
  14881. * The controller corresponding to the users left hand.
  14882. */
  14883. readonly leftController: Nullable<WebVRController>;
  14884. private _rightController;
  14885. /**
  14886. * The controller corresponding to the users right hand.
  14887. */
  14888. readonly rightController: Nullable<WebVRController>;
  14889. /**
  14890. * Casts a ray forward from the vrCamera's gaze.
  14891. * @param length Length of the ray (default: 100)
  14892. * @returns the ray corresponding to the gaze
  14893. */
  14894. getForwardRay(length?: number): Ray;
  14895. /**
  14896. * @hidden
  14897. * Updates the camera based on device's frame data
  14898. */
  14899. _checkInputs(): void;
  14900. /**
  14901. * Updates the poseControlled values based on the input device pose.
  14902. * @param poseData Pose coming from the device
  14903. */
  14904. updateFromDevice(poseData: DevicePose): void;
  14905. private _htmlElementAttached;
  14906. private _detachIfAttached;
  14907. /**
  14908. * WebVR's attach control will start broadcasting frames to the device.
  14909. * Note that in certain browsers (chrome for example) this function must be called
  14910. * within a user-interaction callback. Example:
  14911. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14912. *
  14913. * @param element html element to attach the vrDevice to
  14914. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14915. */
  14916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14917. /**
  14918. * Detaches the camera from the html element and disables VR
  14919. *
  14920. * @param element html element to detach from
  14921. */
  14922. detachControl(element: HTMLElement): void;
  14923. /**
  14924. * @returns the name of this class
  14925. */
  14926. getClassName(): string;
  14927. /**
  14928. * Calls resetPose on the vrDisplay
  14929. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14930. */
  14931. resetToCurrentRotation(): void;
  14932. /**
  14933. * @hidden
  14934. * Updates the rig cameras (left and right eye)
  14935. */
  14936. _updateRigCameras(): void;
  14937. private _workingVector;
  14938. private _oneVector;
  14939. private _workingMatrix;
  14940. private updateCacheCalled;
  14941. private _correctPositionIfNotTrackPosition;
  14942. /**
  14943. * @hidden
  14944. * Updates the cached values of the camera
  14945. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14946. */
  14947. _updateCache(ignoreParentClass?: boolean): void;
  14948. /**
  14949. * @hidden
  14950. * Get current device position in babylon world
  14951. */
  14952. _computeDevicePosition(): void;
  14953. /**
  14954. * Updates the current device position and rotation in the babylon world
  14955. */
  14956. update(): void;
  14957. /**
  14958. * @hidden
  14959. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14960. * @returns an identity matrix
  14961. */
  14962. _getViewMatrix(): Matrix;
  14963. private _tmpMatrix;
  14964. /**
  14965. * This function is called by the two RIG cameras.
  14966. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14967. * @hidden
  14968. */
  14969. _getWebVRViewMatrix(): Matrix;
  14970. /** @hidden */
  14971. _getWebVRProjectionMatrix(): Matrix;
  14972. private _onGamepadConnectedObserver;
  14973. private _onGamepadDisconnectedObserver;
  14974. private _updateCacheWhenTrackingDisabledObserver;
  14975. /**
  14976. * Initializes the controllers and their meshes
  14977. */
  14978. initControllers(): void;
  14979. }
  14980. }
  14981. declare module BABYLON {
  14982. /**
  14983. * Size options for a post process
  14984. */
  14985. export type PostProcessOptions = {
  14986. width: number;
  14987. height: number;
  14988. };
  14989. /**
  14990. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14991. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14992. */
  14993. export class PostProcess {
  14994. /** Name of the PostProcess. */
  14995. name: string;
  14996. /**
  14997. * Gets or sets the unique id of the post process
  14998. */
  14999. uniqueId: number;
  15000. /**
  15001. * Width of the texture to apply the post process on
  15002. */
  15003. width: number;
  15004. /**
  15005. * Height of the texture to apply the post process on
  15006. */
  15007. height: number;
  15008. /**
  15009. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15010. * @hidden
  15011. */
  15012. _outputTexture: Nullable<InternalTexture>;
  15013. /**
  15014. * Sampling mode used by the shader
  15015. * See https://doc.babylonjs.com/classes/3.1/texture
  15016. */
  15017. renderTargetSamplingMode: number;
  15018. /**
  15019. * Clear color to use when screen clearing
  15020. */
  15021. clearColor: Color4;
  15022. /**
  15023. * If the buffer needs to be cleared before applying the post process. (default: true)
  15024. * Should be set to false if shader will overwrite all previous pixels.
  15025. */
  15026. autoClear: boolean;
  15027. /**
  15028. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15029. */
  15030. alphaMode: number;
  15031. /**
  15032. * Sets the setAlphaBlendConstants of the babylon engine
  15033. */
  15034. alphaConstants: Color4;
  15035. /**
  15036. * Animations to be used for the post processing
  15037. */
  15038. animations: Animation[];
  15039. /**
  15040. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15041. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15042. */
  15043. enablePixelPerfectMode: boolean;
  15044. /**
  15045. * Force the postprocess to be applied without taking in account viewport
  15046. */
  15047. forceFullscreenViewport: boolean;
  15048. /**
  15049. * List of inspectable custom properties (used by the Inspector)
  15050. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15051. */
  15052. inspectableCustomProperties: IInspectable[];
  15053. /**
  15054. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15055. *
  15056. * | Value | Type | Description |
  15057. * | ----- | ----------------------------------- | ----------- |
  15058. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15059. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15060. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15061. *
  15062. */
  15063. scaleMode: number;
  15064. /**
  15065. * Force textures to be a power of two (default: false)
  15066. */
  15067. alwaysForcePOT: boolean;
  15068. private _samples;
  15069. /**
  15070. * Number of sample textures (default: 1)
  15071. */
  15072. samples: number;
  15073. /**
  15074. * Modify the scale of the post process to be the same as the viewport (default: false)
  15075. */
  15076. adaptScaleToCurrentViewport: boolean;
  15077. private _camera;
  15078. private _scene;
  15079. private _engine;
  15080. private _options;
  15081. private _reusable;
  15082. private _textureType;
  15083. /**
  15084. * Smart array of input and output textures for the post process.
  15085. * @hidden
  15086. */
  15087. _textures: SmartArray<InternalTexture>;
  15088. /**
  15089. * The index in _textures that corresponds to the output texture.
  15090. * @hidden
  15091. */
  15092. _currentRenderTextureInd: number;
  15093. private _effect;
  15094. private _samplers;
  15095. private _fragmentUrl;
  15096. private _vertexUrl;
  15097. private _parameters;
  15098. private _scaleRatio;
  15099. protected _indexParameters: any;
  15100. private _shareOutputWithPostProcess;
  15101. private _texelSize;
  15102. private _forcedOutputTexture;
  15103. /**
  15104. * Returns the fragment url or shader name used in the post process.
  15105. * @returns the fragment url or name in the shader store.
  15106. */
  15107. getEffectName(): string;
  15108. /**
  15109. * An event triggered when the postprocess is activated.
  15110. */
  15111. onActivateObservable: Observable<Camera>;
  15112. private _onActivateObserver;
  15113. /**
  15114. * A function that is added to the onActivateObservable
  15115. */
  15116. onActivate: Nullable<(camera: Camera) => void>;
  15117. /**
  15118. * An event triggered when the postprocess changes its size.
  15119. */
  15120. onSizeChangedObservable: Observable<PostProcess>;
  15121. private _onSizeChangedObserver;
  15122. /**
  15123. * A function that is added to the onSizeChangedObservable
  15124. */
  15125. onSizeChanged: (postProcess: PostProcess) => void;
  15126. /**
  15127. * An event triggered when the postprocess applies its effect.
  15128. */
  15129. onApplyObservable: Observable<Effect>;
  15130. private _onApplyObserver;
  15131. /**
  15132. * A function that is added to the onApplyObservable
  15133. */
  15134. onApply: (effect: Effect) => void;
  15135. /**
  15136. * An event triggered before rendering the postprocess
  15137. */
  15138. onBeforeRenderObservable: Observable<Effect>;
  15139. private _onBeforeRenderObserver;
  15140. /**
  15141. * A function that is added to the onBeforeRenderObservable
  15142. */
  15143. onBeforeRender: (effect: Effect) => void;
  15144. /**
  15145. * An event triggered after rendering the postprocess
  15146. */
  15147. onAfterRenderObservable: Observable<Effect>;
  15148. private _onAfterRenderObserver;
  15149. /**
  15150. * A function that is added to the onAfterRenderObservable
  15151. */
  15152. onAfterRender: (efect: Effect) => void;
  15153. /**
  15154. * 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
  15155. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15156. */
  15157. inputTexture: InternalTexture;
  15158. /**
  15159. * Gets the camera which post process is applied to.
  15160. * @returns The camera the post process is applied to.
  15161. */
  15162. getCamera(): Camera;
  15163. /**
  15164. * Gets the texel size of the postprocess.
  15165. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15166. */
  15167. readonly texelSize: Vector2;
  15168. /**
  15169. * Creates a new instance PostProcess
  15170. * @param name The name of the PostProcess.
  15171. * @param fragmentUrl The url of the fragment shader to be used.
  15172. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15173. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15174. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15175. * @param camera The camera to apply the render pass to.
  15176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15177. * @param engine The engine which the post process will be applied. (default: current engine)
  15178. * @param reusable If the post process can be reused on the same frame. (default: false)
  15179. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15180. * @param textureType Type of textures used when performing the post process. (default: 0)
  15181. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15182. * @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
  15183. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15184. */
  15185. constructor(
  15186. /** Name of the PostProcess. */
  15187. 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);
  15188. /**
  15189. * Gets a string idenfifying the name of the class
  15190. * @returns "PostProcess" string
  15191. */
  15192. getClassName(): string;
  15193. /**
  15194. * Gets the engine which this post process belongs to.
  15195. * @returns The engine the post process was enabled with.
  15196. */
  15197. getEngine(): Engine;
  15198. /**
  15199. * The effect that is created when initializing the post process.
  15200. * @returns The created effect corresponding the the postprocess.
  15201. */
  15202. getEffect(): Effect;
  15203. /**
  15204. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15205. * @param postProcess The post process to share the output with.
  15206. * @returns This post process.
  15207. */
  15208. shareOutputWith(postProcess: PostProcess): PostProcess;
  15209. /**
  15210. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15211. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15212. */
  15213. useOwnOutput(): void;
  15214. /**
  15215. * Updates the effect with the current post process compile time values and recompiles the shader.
  15216. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15217. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15218. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15219. * @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
  15220. * @param onCompiled Called when the shader has been compiled.
  15221. * @param onError Called if there is an error when compiling a shader.
  15222. */
  15223. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15224. /**
  15225. * The post process is reusable if it can be used multiple times within one frame.
  15226. * @returns If the post process is reusable
  15227. */
  15228. isReusable(): boolean;
  15229. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15230. markTextureDirty(): void;
  15231. /**
  15232. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15233. * 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.
  15234. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15235. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15236. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15237. * @returns The target texture that was bound to be written to.
  15238. */
  15239. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15240. /**
  15241. * If the post process is supported.
  15242. */
  15243. readonly isSupported: boolean;
  15244. /**
  15245. * The aspect ratio of the output texture.
  15246. */
  15247. readonly aspectRatio: number;
  15248. /**
  15249. * Get a value indicating if the post-process is ready to be used
  15250. * @returns true if the post-process is ready (shader is compiled)
  15251. */
  15252. isReady(): boolean;
  15253. /**
  15254. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15255. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15256. */
  15257. apply(): Nullable<Effect>;
  15258. private _disposeTextures;
  15259. /**
  15260. * Disposes the post process.
  15261. * @param camera The camera to dispose the post process on.
  15262. */
  15263. dispose(camera?: Camera): void;
  15264. }
  15265. }
  15266. declare module BABYLON {
  15267. /** @hidden */
  15268. export var kernelBlurVaryingDeclaration: {
  15269. name: string;
  15270. shader: string;
  15271. };
  15272. }
  15273. declare module BABYLON {
  15274. /** @hidden */
  15275. export var kernelBlurFragment: {
  15276. name: string;
  15277. shader: string;
  15278. };
  15279. }
  15280. declare module BABYLON {
  15281. /** @hidden */
  15282. export var kernelBlurFragment2: {
  15283. name: string;
  15284. shader: string;
  15285. };
  15286. }
  15287. declare module BABYLON {
  15288. /** @hidden */
  15289. export var kernelBlurPixelShader: {
  15290. name: string;
  15291. shader: string;
  15292. };
  15293. }
  15294. declare module BABYLON {
  15295. /** @hidden */
  15296. export var kernelBlurVertex: {
  15297. name: string;
  15298. shader: string;
  15299. };
  15300. }
  15301. declare module BABYLON {
  15302. /** @hidden */
  15303. export var kernelBlurVertexShader: {
  15304. name: string;
  15305. shader: string;
  15306. };
  15307. }
  15308. declare module BABYLON {
  15309. /**
  15310. * The Blur Post Process which blurs an image based on a kernel and direction.
  15311. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15312. */
  15313. export class BlurPostProcess extends PostProcess {
  15314. /** The direction in which to blur the image. */
  15315. direction: Vector2;
  15316. private blockCompilation;
  15317. protected _kernel: number;
  15318. protected _idealKernel: number;
  15319. protected _packedFloat: boolean;
  15320. private _staticDefines;
  15321. /**
  15322. * Sets the length in pixels of the blur sample region
  15323. */
  15324. /**
  15325. * Gets the length in pixels of the blur sample region
  15326. */
  15327. kernel: number;
  15328. /**
  15329. * Sets wether or not the blur needs to unpack/repack floats
  15330. */
  15331. /**
  15332. * Gets wether or not the blur is unpacking/repacking floats
  15333. */
  15334. packedFloat: boolean;
  15335. /**
  15336. * Creates a new instance BlurPostProcess
  15337. * @param name The name of the effect.
  15338. * @param direction The direction in which to blur the image.
  15339. * @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.
  15340. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15341. * @param camera The camera to apply the render pass to.
  15342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15343. * @param engine The engine which the post process will be applied. (default: current engine)
  15344. * @param reusable If the post process can be reused on the same frame. (default: false)
  15345. * @param textureType Type of textures used when performing the post process. (default: 0)
  15346. * @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)
  15347. */
  15348. constructor(name: string,
  15349. /** The direction in which to blur the image. */
  15350. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15351. /**
  15352. * Updates the effect with the current post process compile time values and recompiles the shader.
  15353. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15354. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15355. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15356. * @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
  15357. * @param onCompiled Called when the shader has been compiled.
  15358. * @param onError Called if there is an error when compiling a shader.
  15359. */
  15360. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15361. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15362. /**
  15363. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15364. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15365. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15366. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15367. * The gaps between physical kernels are compensated for in the weighting of the samples
  15368. * @param idealKernel Ideal blur kernel.
  15369. * @return Nearest best kernel.
  15370. */
  15371. protected _nearestBestKernel(idealKernel: number): number;
  15372. /**
  15373. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15374. * @param x The point on the Gaussian distribution to sample.
  15375. * @return the value of the Gaussian function at x.
  15376. */
  15377. protected _gaussianWeight(x: number): number;
  15378. /**
  15379. * Generates a string that can be used as a floating point number in GLSL.
  15380. * @param x Value to print.
  15381. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15382. * @return GLSL float string.
  15383. */
  15384. protected _glslFloat(x: number, decimalFigures?: number): string;
  15385. }
  15386. }
  15387. declare module BABYLON {
  15388. /**
  15389. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15390. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15391. * You can then easily use it as a reflectionTexture on a flat surface.
  15392. * In case the surface is not a plane, please consider relying on reflection probes.
  15393. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15394. */
  15395. export class MirrorTexture extends RenderTargetTexture {
  15396. private scene;
  15397. /**
  15398. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15399. * 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.
  15400. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15401. */
  15402. mirrorPlane: Plane;
  15403. /**
  15404. * Define the blur ratio used to blur the reflection if needed.
  15405. */
  15406. blurRatio: number;
  15407. /**
  15408. * Define the adaptive blur kernel used to blur the reflection if needed.
  15409. * This will autocompute the closest best match for the `blurKernel`
  15410. */
  15411. adaptiveBlurKernel: number;
  15412. /**
  15413. * Define the blur kernel used to blur the reflection if needed.
  15414. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15415. */
  15416. blurKernel: number;
  15417. /**
  15418. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15419. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15420. */
  15421. blurKernelX: number;
  15422. /**
  15423. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15425. */
  15426. blurKernelY: number;
  15427. private _autoComputeBlurKernel;
  15428. protected _onRatioRescale(): void;
  15429. private _updateGammaSpace;
  15430. private _imageProcessingConfigChangeObserver;
  15431. private _transformMatrix;
  15432. private _mirrorMatrix;
  15433. private _savedViewMatrix;
  15434. private _blurX;
  15435. private _blurY;
  15436. private _adaptiveBlurKernel;
  15437. private _blurKernelX;
  15438. private _blurKernelY;
  15439. private _blurRatio;
  15440. /**
  15441. * Instantiates a Mirror Texture.
  15442. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15443. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15444. * You can then easily use it as a reflectionTexture on a flat surface.
  15445. * In case the surface is not a plane, please consider relying on reflection probes.
  15446. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15447. * @param name
  15448. * @param size
  15449. * @param scene
  15450. * @param generateMipMaps
  15451. * @param type
  15452. * @param samplingMode
  15453. * @param generateDepthBuffer
  15454. */
  15455. constructor(name: string, size: number | {
  15456. width: number;
  15457. height: number;
  15458. } | {
  15459. ratio: number;
  15460. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15461. private _preparePostProcesses;
  15462. /**
  15463. * Clone the mirror texture.
  15464. * @returns the cloned texture
  15465. */
  15466. clone(): MirrorTexture;
  15467. /**
  15468. * Serialize the texture to a JSON representation you could use in Parse later on
  15469. * @returns the serialized JSON representation
  15470. */
  15471. serialize(): any;
  15472. /**
  15473. * Dispose the texture and release its associated resources.
  15474. */
  15475. dispose(): void;
  15476. }
  15477. }
  15478. declare module BABYLON {
  15479. /**
  15480. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15481. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15482. */
  15483. export class Texture extends BaseTexture {
  15484. /** @hidden */
  15485. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15486. /** @hidden */
  15487. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15488. /** @hidden */
  15489. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15490. /** nearest is mag = nearest and min = nearest and mip = linear */
  15491. static readonly NEAREST_SAMPLINGMODE: number;
  15492. /** nearest is mag = nearest and min = nearest and mip = linear */
  15493. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15494. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15495. static readonly BILINEAR_SAMPLINGMODE: number;
  15496. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15497. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15498. /** Trilinear is mag = linear and min = linear and mip = linear */
  15499. static readonly TRILINEAR_SAMPLINGMODE: number;
  15500. /** Trilinear is mag = linear and min = linear and mip = linear */
  15501. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15502. /** mag = nearest and min = nearest and mip = nearest */
  15503. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15504. /** mag = nearest and min = linear and mip = nearest */
  15505. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15506. /** mag = nearest and min = linear and mip = linear */
  15507. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15508. /** mag = nearest and min = linear and mip = none */
  15509. static readonly NEAREST_LINEAR: number;
  15510. /** mag = nearest and min = nearest and mip = none */
  15511. static readonly NEAREST_NEAREST: number;
  15512. /** mag = linear and min = nearest and mip = nearest */
  15513. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15514. /** mag = linear and min = nearest and mip = linear */
  15515. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15516. /** mag = linear and min = linear and mip = none */
  15517. static readonly LINEAR_LINEAR: number;
  15518. /** mag = linear and min = nearest and mip = none */
  15519. static readonly LINEAR_NEAREST: number;
  15520. /** Explicit coordinates mode */
  15521. static readonly EXPLICIT_MODE: number;
  15522. /** Spherical coordinates mode */
  15523. static readonly SPHERICAL_MODE: number;
  15524. /** Planar coordinates mode */
  15525. static readonly PLANAR_MODE: number;
  15526. /** Cubic coordinates mode */
  15527. static readonly CUBIC_MODE: number;
  15528. /** Projection coordinates mode */
  15529. static readonly PROJECTION_MODE: number;
  15530. /** Inverse Cubic coordinates mode */
  15531. static readonly SKYBOX_MODE: number;
  15532. /** Inverse Cubic coordinates mode */
  15533. static readonly INVCUBIC_MODE: number;
  15534. /** Equirectangular coordinates mode */
  15535. static readonly EQUIRECTANGULAR_MODE: number;
  15536. /** Equirectangular Fixed coordinates mode */
  15537. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15538. /** Equirectangular Fixed Mirrored coordinates mode */
  15539. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15540. /** Texture is not repeating outside of 0..1 UVs */
  15541. static readonly CLAMP_ADDRESSMODE: number;
  15542. /** Texture is repeating outside of 0..1 UVs */
  15543. static readonly WRAP_ADDRESSMODE: number;
  15544. /** Texture is repeating and mirrored */
  15545. static readonly MIRROR_ADDRESSMODE: number;
  15546. /**
  15547. * 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
  15548. */
  15549. static UseSerializedUrlIfAny: boolean;
  15550. /**
  15551. * Define the url of the texture.
  15552. */
  15553. url: Nullable<string>;
  15554. /**
  15555. * Define an offset on the texture to offset the u coordinates of the UVs
  15556. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15557. */
  15558. uOffset: number;
  15559. /**
  15560. * Define an offset on the texture to offset the v coordinates of the UVs
  15561. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15562. */
  15563. vOffset: number;
  15564. /**
  15565. * Define an offset on the texture to scale the u coordinates of the UVs
  15566. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15567. */
  15568. uScale: number;
  15569. /**
  15570. * Define an offset on the texture to scale the v coordinates of the UVs
  15571. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15572. */
  15573. vScale: number;
  15574. /**
  15575. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15576. * @see http://doc.babylonjs.com/how_to/more_materials
  15577. */
  15578. uAng: number;
  15579. /**
  15580. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15581. * @see http://doc.babylonjs.com/how_to/more_materials
  15582. */
  15583. vAng: number;
  15584. /**
  15585. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15586. * @see http://doc.babylonjs.com/how_to/more_materials
  15587. */
  15588. wAng: number;
  15589. /**
  15590. * Defines the center of rotation (U)
  15591. */
  15592. uRotationCenter: number;
  15593. /**
  15594. * Defines the center of rotation (V)
  15595. */
  15596. vRotationCenter: number;
  15597. /**
  15598. * Defines the center of rotation (W)
  15599. */
  15600. wRotationCenter: number;
  15601. /**
  15602. * Are mip maps generated for this texture or not.
  15603. */
  15604. readonly noMipmap: boolean;
  15605. /**
  15606. * List of inspectable custom properties (used by the Inspector)
  15607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15608. */
  15609. inspectableCustomProperties: Nullable<IInspectable[]>;
  15610. private _noMipmap;
  15611. /** @hidden */
  15612. _invertY: boolean;
  15613. private _rowGenerationMatrix;
  15614. private _cachedTextureMatrix;
  15615. private _projectionModeMatrix;
  15616. private _t0;
  15617. private _t1;
  15618. private _t2;
  15619. private _cachedUOffset;
  15620. private _cachedVOffset;
  15621. private _cachedUScale;
  15622. private _cachedVScale;
  15623. private _cachedUAng;
  15624. private _cachedVAng;
  15625. private _cachedWAng;
  15626. private _cachedProjectionMatrixId;
  15627. private _cachedCoordinatesMode;
  15628. /** @hidden */
  15629. protected _initialSamplingMode: number;
  15630. /** @hidden */
  15631. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15632. private _deleteBuffer;
  15633. protected _format: Nullable<number>;
  15634. private _delayedOnLoad;
  15635. private _delayedOnError;
  15636. /**
  15637. * Observable triggered once the texture has been loaded.
  15638. */
  15639. onLoadObservable: Observable<Texture>;
  15640. protected _isBlocking: boolean;
  15641. /**
  15642. * Is the texture preventing material to render while loading.
  15643. * If false, a default texture will be used instead of the loading one during the preparation step.
  15644. */
  15645. isBlocking: boolean;
  15646. /**
  15647. * Get the current sampling mode associated with the texture.
  15648. */
  15649. readonly samplingMode: number;
  15650. /**
  15651. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15652. */
  15653. readonly invertY: boolean;
  15654. /**
  15655. * Instantiates a new texture.
  15656. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15657. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15658. * @param url define the url of the picture to load as a texture
  15659. * @param scene define the scene or engine the texture will belong to
  15660. * @param noMipmap define if the texture will require mip maps or not
  15661. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15662. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15663. * @param onLoad define a callback triggered when the texture has been loaded
  15664. * @param onError define a callback triggered when an error occurred during the loading session
  15665. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15666. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15667. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15668. */
  15669. 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);
  15670. /**
  15671. * Update the url (and optional buffer) of this texture if url was null during construction.
  15672. * @param url the url of the texture
  15673. * @param buffer the buffer of the texture (defaults to null)
  15674. * @param onLoad callback called when the texture is loaded (defaults to null)
  15675. */
  15676. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15677. /**
  15678. * Finish the loading sequence of a texture flagged as delayed load.
  15679. * @hidden
  15680. */
  15681. delayLoad(): void;
  15682. private _prepareRowForTextureGeneration;
  15683. /**
  15684. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15685. * @returns the transform matrix of the texture.
  15686. */
  15687. getTextureMatrix(): Matrix;
  15688. /**
  15689. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15690. * @returns The reflection texture transform
  15691. */
  15692. getReflectionTextureMatrix(): Matrix;
  15693. /**
  15694. * Clones the texture.
  15695. * @returns the cloned texture
  15696. */
  15697. clone(): Texture;
  15698. /**
  15699. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15700. * @returns The JSON representation of the texture
  15701. */
  15702. serialize(): any;
  15703. /**
  15704. * Get the current class name of the texture useful for serialization or dynamic coding.
  15705. * @returns "Texture"
  15706. */
  15707. getClassName(): string;
  15708. /**
  15709. * Dispose the texture and release its associated resources.
  15710. */
  15711. dispose(): void;
  15712. /**
  15713. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15714. * @param parsedTexture Define the JSON representation of the texture
  15715. * @param scene Define the scene the parsed texture should be instantiated in
  15716. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15717. * @returns The parsed texture if successful
  15718. */
  15719. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15720. /**
  15721. * Creates a texture from its base 64 representation.
  15722. * @param data Define the base64 payload without the data: prefix
  15723. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15724. * @param scene Define the scene the texture should belong to
  15725. * @param noMipmap Forces the texture to not create mip map information if true
  15726. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15727. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15728. * @param onLoad define a callback triggered when the texture has been loaded
  15729. * @param onError define a callback triggered when an error occurred during the loading session
  15730. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15731. * @returns the created texture
  15732. */
  15733. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15734. /**
  15735. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15736. * @param data Define the base64 payload without the data: prefix
  15737. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15738. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15739. * @param scene Define the scene the texture should belong to
  15740. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15741. * @param noMipmap Forces the texture to not create mip map information if true
  15742. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15743. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15744. * @param onLoad define a callback triggered when the texture has been loaded
  15745. * @param onError define a callback triggered when an error occurred during the loading session
  15746. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15747. * @returns the created texture
  15748. */
  15749. 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;
  15750. }
  15751. }
  15752. declare module BABYLON {
  15753. /**
  15754. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15755. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15756. */
  15757. export class PostProcessManager {
  15758. private _scene;
  15759. private _indexBuffer;
  15760. private _vertexBuffers;
  15761. /**
  15762. * Creates a new instance PostProcess
  15763. * @param scene The scene that the post process is associated with.
  15764. */
  15765. constructor(scene: Scene);
  15766. private _prepareBuffers;
  15767. private _buildIndexBuffer;
  15768. /**
  15769. * Rebuilds the vertex buffers of the manager.
  15770. * @hidden
  15771. */
  15772. _rebuild(): void;
  15773. /**
  15774. * Prepares a frame to be run through a post process.
  15775. * @param sourceTexture The input texture to the post procesess. (default: null)
  15776. * @param postProcesses An array of post processes to be run. (default: null)
  15777. * @returns True if the post processes were able to be run.
  15778. * @hidden
  15779. */
  15780. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15781. /**
  15782. * Manually render a set of post processes to a texture.
  15783. * @param postProcesses An array of post processes to be run.
  15784. * @param targetTexture The target texture to render to.
  15785. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15786. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15787. * @param lodLevel defines which lod of the texture to render to
  15788. */
  15789. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15790. /**
  15791. * Finalize the result of the output of the postprocesses.
  15792. * @param doNotPresent If true the result will not be displayed to the screen.
  15793. * @param targetTexture The target texture to render to.
  15794. * @param faceIndex The index of the face to bind the target texture to.
  15795. * @param postProcesses The array of post processes to render.
  15796. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15797. * @hidden
  15798. */
  15799. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15800. /**
  15801. * Disposes of the post process manager.
  15802. */
  15803. dispose(): void;
  15804. }
  15805. }
  15806. declare module BABYLON {
  15807. /** Interface used by value gradients (color, factor, ...) */
  15808. export interface IValueGradient {
  15809. /**
  15810. * Gets or sets the gradient value (between 0 and 1)
  15811. */
  15812. gradient: number;
  15813. }
  15814. /** Class used to store color4 gradient */
  15815. export class ColorGradient implements IValueGradient {
  15816. /**
  15817. * Gets or sets the gradient value (between 0 and 1)
  15818. */
  15819. gradient: number;
  15820. /**
  15821. * Gets or sets first associated color
  15822. */
  15823. color1: Color4;
  15824. /**
  15825. * Gets or sets second associated color
  15826. */
  15827. color2?: Color4;
  15828. /**
  15829. * Will get a color picked randomly between color1 and color2.
  15830. * If color2 is undefined then color1 will be used
  15831. * @param result defines the target Color4 to store the result in
  15832. */
  15833. getColorToRef(result: Color4): void;
  15834. }
  15835. /** Class used to store color 3 gradient */
  15836. export class Color3Gradient implements IValueGradient {
  15837. /**
  15838. * Gets or sets the gradient value (between 0 and 1)
  15839. */
  15840. gradient: number;
  15841. /**
  15842. * Gets or sets the associated color
  15843. */
  15844. color: Color3;
  15845. }
  15846. /** Class used to store factor gradient */
  15847. export class FactorGradient implements IValueGradient {
  15848. /**
  15849. * Gets or sets the gradient value (between 0 and 1)
  15850. */
  15851. gradient: number;
  15852. /**
  15853. * Gets or sets first associated factor
  15854. */
  15855. factor1: number;
  15856. /**
  15857. * Gets or sets second associated factor
  15858. */
  15859. factor2?: number;
  15860. /**
  15861. * Will get a number picked randomly between factor1 and factor2.
  15862. * If factor2 is undefined then factor1 will be used
  15863. * @returns the picked number
  15864. */
  15865. getFactor(): number;
  15866. }
  15867. /**
  15868. * Helper used to simplify some generic gradient tasks
  15869. */
  15870. export class GradientHelper {
  15871. /**
  15872. * Gets the current gradient from an array of IValueGradient
  15873. * @param ratio defines the current ratio to get
  15874. * @param gradients defines the array of IValueGradient
  15875. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15876. */
  15877. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15878. }
  15879. }
  15880. declare module BABYLON {
  15881. interface AbstractScene {
  15882. /**
  15883. * The list of procedural textures added to the scene
  15884. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15885. */
  15886. proceduralTextures: Array<ProceduralTexture>;
  15887. }
  15888. /**
  15889. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15890. * in a given scene.
  15891. */
  15892. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15893. /**
  15894. * The component name helpfull to identify the component in the list of scene components.
  15895. */
  15896. readonly name: string;
  15897. /**
  15898. * The scene the component belongs to.
  15899. */
  15900. scene: Scene;
  15901. /**
  15902. * Creates a new instance of the component for the given scene
  15903. * @param scene Defines the scene to register the component in
  15904. */
  15905. constructor(scene: Scene);
  15906. /**
  15907. * Registers the component in a given scene
  15908. */
  15909. register(): void;
  15910. /**
  15911. * Rebuilds the elements related to this component in case of
  15912. * context lost for instance.
  15913. */
  15914. rebuild(): void;
  15915. /**
  15916. * Disposes the component and the associated ressources.
  15917. */
  15918. dispose(): void;
  15919. private _beforeClear;
  15920. }
  15921. }
  15922. declare module BABYLON {
  15923. interface Engine {
  15924. /**
  15925. * Creates a new render target cube texture
  15926. * @param size defines the size of the texture
  15927. * @param options defines the options used to create the texture
  15928. * @returns a new render target cube texture stored in an InternalTexture
  15929. */
  15930. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15931. }
  15932. }
  15933. declare module BABYLON {
  15934. /** @hidden */
  15935. export var proceduralVertexShader: {
  15936. name: string;
  15937. shader: string;
  15938. };
  15939. }
  15940. declare module BABYLON {
  15941. /**
  15942. * 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.
  15943. * This is the base class of any Procedural texture and contains most of the shareable code.
  15944. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15945. */
  15946. export class ProceduralTexture extends Texture {
  15947. isCube: boolean;
  15948. /**
  15949. * Define if the texture is enabled or not (disabled texture will not render)
  15950. */
  15951. isEnabled: boolean;
  15952. /**
  15953. * Define if the texture must be cleared before rendering (default is true)
  15954. */
  15955. autoClear: boolean;
  15956. /**
  15957. * Callback called when the texture is generated
  15958. */
  15959. onGenerated: () => void;
  15960. /**
  15961. * Event raised when the texture is generated
  15962. */
  15963. onGeneratedObservable: Observable<ProceduralTexture>;
  15964. /** @hidden */
  15965. _generateMipMaps: boolean;
  15966. /** @hidden **/
  15967. _effect: Effect;
  15968. /** @hidden */
  15969. _textures: {
  15970. [key: string]: Texture;
  15971. };
  15972. private _size;
  15973. private _currentRefreshId;
  15974. private _refreshRate;
  15975. private _vertexBuffers;
  15976. private _indexBuffer;
  15977. private _uniforms;
  15978. private _samplers;
  15979. private _fragment;
  15980. private _floats;
  15981. private _ints;
  15982. private _floatsArrays;
  15983. private _colors3;
  15984. private _colors4;
  15985. private _vectors2;
  15986. private _vectors3;
  15987. private _matrices;
  15988. private _fallbackTexture;
  15989. private _fallbackTextureUsed;
  15990. private _engine;
  15991. private _cachedDefines;
  15992. private _contentUpdateId;
  15993. private _contentData;
  15994. /**
  15995. * Instantiates a new procedural texture.
  15996. * 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.
  15997. * This is the base class of any Procedural texture and contains most of the shareable code.
  15998. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15999. * @param name Define the name of the texture
  16000. * @param size Define the size of the texture to create
  16001. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16002. * @param scene Define the scene the texture belongs to
  16003. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16004. * @param generateMipMaps Define if the texture should creates mip maps or not
  16005. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16006. */
  16007. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16008. /**
  16009. * The effect that is created when initializing the post process.
  16010. * @returns The created effect corresponding the the postprocess.
  16011. */
  16012. getEffect(): Effect;
  16013. /**
  16014. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16015. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16016. */
  16017. getContent(): Nullable<ArrayBufferView>;
  16018. private _createIndexBuffer;
  16019. /** @hidden */
  16020. _rebuild(): void;
  16021. /**
  16022. * Resets the texture in order to recreate its associated resources.
  16023. * This can be called in case of context loss
  16024. */
  16025. reset(): void;
  16026. protected _getDefines(): string;
  16027. /**
  16028. * Is the texture ready to be used ? (rendered at least once)
  16029. * @returns true if ready, otherwise, false.
  16030. */
  16031. isReady(): boolean;
  16032. /**
  16033. * Resets the refresh counter of the texture and start bak from scratch.
  16034. * Could be useful to regenerate the texture if it is setup to render only once.
  16035. */
  16036. resetRefreshCounter(): void;
  16037. /**
  16038. * Set the fragment shader to use in order to render the texture.
  16039. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16040. */
  16041. setFragment(fragment: any): void;
  16042. /**
  16043. * Define the refresh rate of the texture or the rendering frequency.
  16044. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16045. */
  16046. refreshRate: number;
  16047. /** @hidden */
  16048. _shouldRender(): boolean;
  16049. /**
  16050. * Get the size the texture is rendering at.
  16051. * @returns the size (texture is always squared)
  16052. */
  16053. getRenderSize(): number;
  16054. /**
  16055. * Resize the texture to new value.
  16056. * @param size Define the new size the texture should have
  16057. * @param generateMipMaps Define whether the new texture should create mip maps
  16058. */
  16059. resize(size: number, generateMipMaps: boolean): void;
  16060. private _checkUniform;
  16061. /**
  16062. * Set a texture in the shader program used to render.
  16063. * @param name Define the name of the uniform samplers as defined in the shader
  16064. * @param texture Define the texture to bind to this sampler
  16065. * @return the texture itself allowing "fluent" like uniform updates
  16066. */
  16067. setTexture(name: string, texture: Texture): ProceduralTexture;
  16068. /**
  16069. * Set a float in the shader.
  16070. * @param name Define the name of the uniform as defined in the shader
  16071. * @param value Define the value to give to the uniform
  16072. * @return the texture itself allowing "fluent" like uniform updates
  16073. */
  16074. setFloat(name: string, value: number): ProceduralTexture;
  16075. /**
  16076. * Set a int in the shader.
  16077. * @param name Define the name of the uniform as defined in the shader
  16078. * @param value Define the value to give to the uniform
  16079. * @return the texture itself allowing "fluent" like uniform updates
  16080. */
  16081. setInt(name: string, value: number): ProceduralTexture;
  16082. /**
  16083. * Set an array of floats in the shader.
  16084. * @param name Define the name of the uniform as defined in the shader
  16085. * @param value Define the value to give to the uniform
  16086. * @return the texture itself allowing "fluent" like uniform updates
  16087. */
  16088. setFloats(name: string, value: number[]): ProceduralTexture;
  16089. /**
  16090. * Set a vec3 in the shader from a Color3.
  16091. * @param name Define the name of the uniform as defined in the shader
  16092. * @param value Define the value to give to the uniform
  16093. * @return the texture itself allowing "fluent" like uniform updates
  16094. */
  16095. setColor3(name: string, value: Color3): ProceduralTexture;
  16096. /**
  16097. * Set a vec4 in the shader from a Color4.
  16098. * @param name Define the name of the uniform as defined in the shader
  16099. * @param value Define the value to give to the uniform
  16100. * @return the texture itself allowing "fluent" like uniform updates
  16101. */
  16102. setColor4(name: string, value: Color4): ProceduralTexture;
  16103. /**
  16104. * Set a vec2 in the shader from a Vector2.
  16105. * @param name Define the name of the uniform as defined in the shader
  16106. * @param value Define the value to give to the uniform
  16107. * @return the texture itself allowing "fluent" like uniform updates
  16108. */
  16109. setVector2(name: string, value: Vector2): ProceduralTexture;
  16110. /**
  16111. * Set a vec3 in the shader from a Vector3.
  16112. * @param name Define the name of the uniform as defined in the shader
  16113. * @param value Define the value to give to the uniform
  16114. * @return the texture itself allowing "fluent" like uniform updates
  16115. */
  16116. setVector3(name: string, value: Vector3): ProceduralTexture;
  16117. /**
  16118. * Set a mat4 in the shader from a MAtrix.
  16119. * @param name Define the name of the uniform as defined in the shader
  16120. * @param value Define the value to give to the uniform
  16121. * @return the texture itself allowing "fluent" like uniform updates
  16122. */
  16123. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16124. /**
  16125. * Render the texture to its associated render target.
  16126. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16127. */
  16128. render(useCameraPostProcess?: boolean): void;
  16129. /**
  16130. * Clone the texture.
  16131. * @returns the cloned texture
  16132. */
  16133. clone(): ProceduralTexture;
  16134. /**
  16135. * Dispose the texture and release its asoociated resources.
  16136. */
  16137. dispose(): void;
  16138. }
  16139. }
  16140. declare module BABYLON {
  16141. /**
  16142. * This represents the base class for particle system in Babylon.
  16143. * 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.
  16144. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16145. * @example https://doc.babylonjs.com/babylon101/particles
  16146. */
  16147. export class BaseParticleSystem {
  16148. /**
  16149. * Source color is added to the destination color without alpha affecting the result
  16150. */
  16151. static BLENDMODE_ONEONE: number;
  16152. /**
  16153. * Blend current color and particle color using particle’s alpha
  16154. */
  16155. static BLENDMODE_STANDARD: number;
  16156. /**
  16157. * Add current color and particle color multiplied by particle’s alpha
  16158. */
  16159. static BLENDMODE_ADD: number;
  16160. /**
  16161. * Multiply current color with particle color
  16162. */
  16163. static BLENDMODE_MULTIPLY: number;
  16164. /**
  16165. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16166. */
  16167. static BLENDMODE_MULTIPLYADD: number;
  16168. /**
  16169. * List of animations used by the particle system.
  16170. */
  16171. animations: Animation[];
  16172. /**
  16173. * The id of the Particle system.
  16174. */
  16175. id: string;
  16176. /**
  16177. * The friendly name of the Particle system.
  16178. */
  16179. name: string;
  16180. /**
  16181. * The rendering group used by the Particle system to chose when to render.
  16182. */
  16183. renderingGroupId: number;
  16184. /**
  16185. * The emitter represents the Mesh or position we are attaching the particle system to.
  16186. */
  16187. emitter: Nullable<AbstractMesh | Vector3>;
  16188. /**
  16189. * The maximum number of particles to emit per frame
  16190. */
  16191. emitRate: number;
  16192. /**
  16193. * If you want to launch only a few particles at once, that can be done, as well.
  16194. */
  16195. manualEmitCount: number;
  16196. /**
  16197. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16198. */
  16199. updateSpeed: number;
  16200. /**
  16201. * The amount of time the particle system is running (depends of the overall update speed).
  16202. */
  16203. targetStopDuration: number;
  16204. /**
  16205. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16206. */
  16207. disposeOnStop: boolean;
  16208. /**
  16209. * Minimum power of emitting particles.
  16210. */
  16211. minEmitPower: number;
  16212. /**
  16213. * Maximum power of emitting particles.
  16214. */
  16215. maxEmitPower: number;
  16216. /**
  16217. * Minimum life time of emitting particles.
  16218. */
  16219. minLifeTime: number;
  16220. /**
  16221. * Maximum life time of emitting particles.
  16222. */
  16223. maxLifeTime: number;
  16224. /**
  16225. * Minimum Size of emitting particles.
  16226. */
  16227. minSize: number;
  16228. /**
  16229. * Maximum Size of emitting particles.
  16230. */
  16231. maxSize: number;
  16232. /**
  16233. * Minimum scale of emitting particles on X axis.
  16234. */
  16235. minScaleX: number;
  16236. /**
  16237. * Maximum scale of emitting particles on X axis.
  16238. */
  16239. maxScaleX: number;
  16240. /**
  16241. * Minimum scale of emitting particles on Y axis.
  16242. */
  16243. minScaleY: number;
  16244. /**
  16245. * Maximum scale of emitting particles on Y axis.
  16246. */
  16247. maxScaleY: number;
  16248. /**
  16249. * Gets or sets the minimal initial rotation in radians.
  16250. */
  16251. minInitialRotation: number;
  16252. /**
  16253. * Gets or sets the maximal initial rotation in radians.
  16254. */
  16255. maxInitialRotation: number;
  16256. /**
  16257. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16258. */
  16259. minAngularSpeed: number;
  16260. /**
  16261. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16262. */
  16263. maxAngularSpeed: number;
  16264. /**
  16265. * The texture used to render each particle. (this can be a spritesheet)
  16266. */
  16267. particleTexture: Nullable<Texture>;
  16268. /**
  16269. * The layer mask we are rendering the particles through.
  16270. */
  16271. layerMask: number;
  16272. /**
  16273. * This can help using your own shader to render the particle system.
  16274. * The according effect will be created
  16275. */
  16276. customShader: any;
  16277. /**
  16278. * By default particle system starts as soon as they are created. This prevents the
  16279. * automatic start to happen and let you decide when to start emitting particles.
  16280. */
  16281. preventAutoStart: boolean;
  16282. private _noiseTexture;
  16283. /**
  16284. * Gets or sets a texture used to add random noise to particle positions
  16285. */
  16286. noiseTexture: Nullable<ProceduralTexture>;
  16287. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16288. noiseStrength: Vector3;
  16289. /**
  16290. * Callback triggered when the particle animation is ending.
  16291. */
  16292. onAnimationEnd: Nullable<() => void>;
  16293. /**
  16294. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16295. */
  16296. blendMode: number;
  16297. /**
  16298. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16299. * to override the particles.
  16300. */
  16301. forceDepthWrite: boolean;
  16302. /** 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 */
  16303. preWarmCycles: number;
  16304. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16305. preWarmStepOffset: number;
  16306. /**
  16307. * 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)
  16308. */
  16309. spriteCellChangeSpeed: number;
  16310. /**
  16311. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16312. */
  16313. startSpriteCellID: number;
  16314. /**
  16315. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16316. */
  16317. endSpriteCellID: number;
  16318. /**
  16319. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16320. */
  16321. spriteCellWidth: number;
  16322. /**
  16323. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16324. */
  16325. spriteCellHeight: number;
  16326. /**
  16327. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16328. */
  16329. spriteRandomStartCell: boolean;
  16330. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16331. translationPivot: Vector2;
  16332. /** @hidden */
  16333. protected _isAnimationSheetEnabled: boolean;
  16334. /**
  16335. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16336. */
  16337. beginAnimationOnStart: boolean;
  16338. /**
  16339. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16340. */
  16341. beginAnimationFrom: number;
  16342. /**
  16343. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16344. */
  16345. beginAnimationTo: number;
  16346. /**
  16347. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16348. */
  16349. beginAnimationLoop: boolean;
  16350. /**
  16351. * Gets or sets a world offset applied to all particles
  16352. */
  16353. worldOffset: Vector3;
  16354. /**
  16355. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16356. */
  16357. isAnimationSheetEnabled: boolean;
  16358. /**
  16359. * Get hosting scene
  16360. * @returns the scene
  16361. */
  16362. getScene(): Scene;
  16363. /**
  16364. * You can use gravity if you want to give an orientation to your particles.
  16365. */
  16366. gravity: Vector3;
  16367. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16368. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16369. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16370. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16371. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16372. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16373. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16374. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16375. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16376. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16377. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16378. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16379. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16380. /**
  16381. * Defines the delay in milliseconds before starting the system (0 by default)
  16382. */
  16383. startDelay: number;
  16384. /**
  16385. * Gets the current list of drag gradients.
  16386. * You must use addDragGradient and removeDragGradient to udpate this list
  16387. * @returns the list of drag gradients
  16388. */
  16389. getDragGradients(): Nullable<Array<FactorGradient>>;
  16390. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16391. limitVelocityDamping: number;
  16392. /**
  16393. * Gets the current list of limit velocity gradients.
  16394. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16395. * @returns the list of limit velocity gradients
  16396. */
  16397. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16398. /**
  16399. * Gets the current list of color gradients.
  16400. * You must use addColorGradient and removeColorGradient to udpate this list
  16401. * @returns the list of color gradients
  16402. */
  16403. getColorGradients(): Nullable<Array<ColorGradient>>;
  16404. /**
  16405. * Gets the current list of size gradients.
  16406. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16407. * @returns the list of size gradients
  16408. */
  16409. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16410. /**
  16411. * Gets the current list of color remap gradients.
  16412. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16413. * @returns the list of color remap gradients
  16414. */
  16415. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16416. /**
  16417. * Gets the current list of alpha remap gradients.
  16418. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16419. * @returns the list of alpha remap gradients
  16420. */
  16421. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16422. /**
  16423. * Gets the current list of life time gradients.
  16424. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16425. * @returns the list of life time gradients
  16426. */
  16427. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16428. /**
  16429. * Gets the current list of angular speed gradients.
  16430. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16431. * @returns the list of angular speed gradients
  16432. */
  16433. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16434. /**
  16435. * Gets the current list of velocity gradients.
  16436. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16437. * @returns the list of velocity gradients
  16438. */
  16439. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16440. /**
  16441. * Gets the current list of start size gradients.
  16442. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16443. * @returns the list of start size gradients
  16444. */
  16445. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16446. /**
  16447. * Gets the current list of emit rate gradients.
  16448. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16449. * @returns the list of emit rate gradients
  16450. */
  16451. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16452. /**
  16453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16454. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16455. */
  16456. direction1: Vector3;
  16457. /**
  16458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16459. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16460. */
  16461. direction2: Vector3;
  16462. /**
  16463. * 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.
  16464. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16465. */
  16466. minEmitBox: Vector3;
  16467. /**
  16468. * 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.
  16469. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16470. */
  16471. maxEmitBox: Vector3;
  16472. /**
  16473. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16474. */
  16475. color1: Color4;
  16476. /**
  16477. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16478. */
  16479. color2: Color4;
  16480. /**
  16481. * Color the particle will have at the end of its lifetime
  16482. */
  16483. colorDead: Color4;
  16484. /**
  16485. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16486. */
  16487. textureMask: Color4;
  16488. /**
  16489. * The particle emitter type defines the emitter used by the particle system.
  16490. * It can be for example box, sphere, or cone...
  16491. */
  16492. particleEmitterType: IParticleEmitterType;
  16493. /** @hidden */
  16494. _isSubEmitter: boolean;
  16495. /**
  16496. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16497. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16498. */
  16499. billboardMode: number;
  16500. protected _isBillboardBased: boolean;
  16501. /**
  16502. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16503. */
  16504. isBillboardBased: boolean;
  16505. /**
  16506. * The scene the particle system belongs to.
  16507. */
  16508. protected _scene: Scene;
  16509. /**
  16510. * Local cache of defines for image processing.
  16511. */
  16512. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16513. /**
  16514. * Default configuration related to image processing available in the standard Material.
  16515. */
  16516. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16517. /**
  16518. * Gets the image processing configuration used either in this material.
  16519. */
  16520. /**
  16521. * Sets the Default image processing configuration used either in the this material.
  16522. *
  16523. * If sets to null, the scene one is in use.
  16524. */
  16525. imageProcessingConfiguration: ImageProcessingConfiguration;
  16526. /**
  16527. * Attaches a new image processing configuration to the Standard Material.
  16528. * @param configuration
  16529. */
  16530. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16531. /** @hidden */
  16532. protected _reset(): void;
  16533. /** @hidden */
  16534. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16535. /**
  16536. * Instantiates a particle system.
  16537. * 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.
  16538. * @param name The name of the particle system
  16539. */
  16540. constructor(name: string);
  16541. /**
  16542. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16545. * @returns the emitter
  16546. */
  16547. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16548. /**
  16549. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16550. * @param radius The radius of the hemisphere to emit from
  16551. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16552. * @returns the emitter
  16553. */
  16554. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16555. /**
  16556. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16557. * @param radius The radius of the sphere to emit from
  16558. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16559. * @returns the emitter
  16560. */
  16561. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16562. /**
  16563. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16564. * @param radius The radius of the sphere to emit from
  16565. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16566. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16567. * @returns the emitter
  16568. */
  16569. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16570. /**
  16571. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16572. * @param radius The radius of the emission cylinder
  16573. * @param height The height of the emission cylinder
  16574. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16575. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16576. * @returns the emitter
  16577. */
  16578. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16579. /**
  16580. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16581. * @param radius The radius of the cylinder to emit from
  16582. * @param height The height of the emission cylinder
  16583. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16586. * @returns the emitter
  16587. */
  16588. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16589. /**
  16590. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16591. * @param radius The radius of the cone to emit from
  16592. * @param angle The base angle of the cone
  16593. * @returns the emitter
  16594. */
  16595. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16596. /**
  16597. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16600. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16601. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16602. * @returns the emitter
  16603. */
  16604. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16605. }
  16606. }
  16607. declare module BABYLON {
  16608. /**
  16609. * Type of sub emitter
  16610. */
  16611. export enum SubEmitterType {
  16612. /**
  16613. * Attached to the particle over it's lifetime
  16614. */
  16615. ATTACHED = 0,
  16616. /**
  16617. * Created when the particle dies
  16618. */
  16619. END = 1
  16620. }
  16621. /**
  16622. * Sub emitter class used to emit particles from an existing particle
  16623. */
  16624. export class SubEmitter {
  16625. /**
  16626. * the particle system to be used by the sub emitter
  16627. */
  16628. particleSystem: ParticleSystem;
  16629. /**
  16630. * Type of the submitter (Default: END)
  16631. */
  16632. type: SubEmitterType;
  16633. /**
  16634. * 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)
  16635. * Note: This only is supported when using an emitter of type Mesh
  16636. */
  16637. inheritDirection: boolean;
  16638. /**
  16639. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16640. */
  16641. inheritedVelocityAmount: number;
  16642. /**
  16643. * Creates a sub emitter
  16644. * @param particleSystem the particle system to be used by the sub emitter
  16645. */
  16646. constructor(
  16647. /**
  16648. * the particle system to be used by the sub emitter
  16649. */
  16650. particleSystem: ParticleSystem);
  16651. /**
  16652. * Clones the sub emitter
  16653. * @returns the cloned sub emitter
  16654. */
  16655. clone(): SubEmitter;
  16656. /**
  16657. * Serialize current object to a JSON object
  16658. * @returns the serialized object
  16659. */
  16660. serialize(): any;
  16661. /** @hidden */
  16662. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16663. /**
  16664. * Creates a new SubEmitter from a serialized JSON version
  16665. * @param serializationObject defines the JSON object to read from
  16666. * @param scene defines the hosting scene
  16667. * @param rootUrl defines the rootUrl for data loading
  16668. * @returns a new SubEmitter
  16669. */
  16670. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16671. /** Release associated resources */
  16672. dispose(): void;
  16673. }
  16674. }
  16675. declare module BABYLON {
  16676. /** @hidden */
  16677. export var clipPlaneFragmentDeclaration: {
  16678. name: string;
  16679. shader: string;
  16680. };
  16681. }
  16682. declare module BABYLON {
  16683. /** @hidden */
  16684. export var imageProcessingDeclaration: {
  16685. name: string;
  16686. shader: string;
  16687. };
  16688. }
  16689. declare module BABYLON {
  16690. /** @hidden */
  16691. export var imageProcessingFunctions: {
  16692. name: string;
  16693. shader: string;
  16694. };
  16695. }
  16696. declare module BABYLON {
  16697. /** @hidden */
  16698. export var clipPlaneFragment: {
  16699. name: string;
  16700. shader: string;
  16701. };
  16702. }
  16703. declare module BABYLON {
  16704. /** @hidden */
  16705. export var particlesPixelShader: {
  16706. name: string;
  16707. shader: string;
  16708. };
  16709. }
  16710. declare module BABYLON {
  16711. /** @hidden */
  16712. export var clipPlaneVertexDeclaration: {
  16713. name: string;
  16714. shader: string;
  16715. };
  16716. }
  16717. declare module BABYLON {
  16718. /** @hidden */
  16719. export var clipPlaneVertex: {
  16720. name: string;
  16721. shader: string;
  16722. };
  16723. }
  16724. declare module BABYLON {
  16725. /** @hidden */
  16726. export var particlesVertexShader: {
  16727. name: string;
  16728. shader: string;
  16729. };
  16730. }
  16731. declare module BABYLON {
  16732. /**
  16733. * This represents a particle system in Babylon.
  16734. * 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.
  16735. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16736. * @example https://doc.babylonjs.com/babylon101/particles
  16737. */
  16738. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16739. /**
  16740. * Billboard mode will only apply to Y axis
  16741. */
  16742. static readonly BILLBOARDMODE_Y: number;
  16743. /**
  16744. * Billboard mode will apply to all axes
  16745. */
  16746. static readonly BILLBOARDMODE_ALL: number;
  16747. /**
  16748. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16749. */
  16750. static readonly BILLBOARDMODE_STRETCHED: number;
  16751. /**
  16752. * This function can be defined to provide custom update for active particles.
  16753. * This function will be called instead of regular update (age, position, color, etc.).
  16754. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16755. */
  16756. updateFunction: (particles: Particle[]) => void;
  16757. private _emitterWorldMatrix;
  16758. /**
  16759. * This function can be defined to specify initial direction for every new particle.
  16760. * It by default use the emitterType defined function
  16761. */
  16762. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16763. /**
  16764. * This function can be defined to specify initial position for every new particle.
  16765. * It by default use the emitterType defined function
  16766. */
  16767. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16768. /**
  16769. * @hidden
  16770. */
  16771. _inheritedVelocityOffset: Vector3;
  16772. /**
  16773. * An event triggered when the system is disposed
  16774. */
  16775. onDisposeObservable: Observable<ParticleSystem>;
  16776. private _onDisposeObserver;
  16777. /**
  16778. * Sets a callback that will be triggered when the system is disposed
  16779. */
  16780. onDispose: () => void;
  16781. private _particles;
  16782. private _epsilon;
  16783. private _capacity;
  16784. private _stockParticles;
  16785. private _newPartsExcess;
  16786. private _vertexData;
  16787. private _vertexBuffer;
  16788. private _vertexBuffers;
  16789. private _spriteBuffer;
  16790. private _indexBuffer;
  16791. private _effect;
  16792. private _customEffect;
  16793. private _cachedDefines;
  16794. private _scaledColorStep;
  16795. private _colorDiff;
  16796. private _scaledDirection;
  16797. private _scaledGravity;
  16798. private _currentRenderId;
  16799. private _alive;
  16800. private _useInstancing;
  16801. private _started;
  16802. private _stopped;
  16803. private _actualFrame;
  16804. private _scaledUpdateSpeed;
  16805. private _vertexBufferSize;
  16806. /** @hidden */
  16807. _currentEmitRateGradient: Nullable<FactorGradient>;
  16808. /** @hidden */
  16809. _currentEmitRate1: number;
  16810. /** @hidden */
  16811. _currentEmitRate2: number;
  16812. /** @hidden */
  16813. _currentStartSizeGradient: Nullable<FactorGradient>;
  16814. /** @hidden */
  16815. _currentStartSize1: number;
  16816. /** @hidden */
  16817. _currentStartSize2: number;
  16818. private readonly _rawTextureWidth;
  16819. private _rampGradientsTexture;
  16820. private _useRampGradients;
  16821. /** Gets or sets a boolean indicating that ramp gradients must be used
  16822. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16823. */
  16824. useRampGradients: boolean;
  16825. /**
  16826. * 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.
  16827. * 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: [])
  16828. */
  16829. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16830. private _subEmitters;
  16831. /**
  16832. * @hidden
  16833. * If the particle systems emitter should be disposed when the particle system is disposed
  16834. */
  16835. _disposeEmitterOnDispose: boolean;
  16836. /**
  16837. * The current active Sub-systems, this property is used by the root particle system only.
  16838. */
  16839. activeSubSystems: Array<ParticleSystem>;
  16840. private _rootParticleSystem;
  16841. /**
  16842. * Gets the current list of active particles
  16843. */
  16844. readonly particles: Particle[];
  16845. /**
  16846. * Returns the string "ParticleSystem"
  16847. * @returns a string containing the class name
  16848. */
  16849. getClassName(): string;
  16850. /**
  16851. * Instantiates a particle system.
  16852. * 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.
  16853. * @param name The name of the particle system
  16854. * @param capacity The max number of particles alive at the same time
  16855. * @param scene The scene the particle system belongs to
  16856. * @param customEffect a custom effect used to change the way particles are rendered by default
  16857. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16858. * @param epsilon Offset used to render the particles
  16859. */
  16860. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16861. private _addFactorGradient;
  16862. private _removeFactorGradient;
  16863. /**
  16864. * Adds a new life time gradient
  16865. * @param gradient defines the gradient to use (between 0 and 1)
  16866. * @param factor defines the life time factor to affect to the specified gradient
  16867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16868. * @returns the current particle system
  16869. */
  16870. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16871. /**
  16872. * Remove a specific life time gradient
  16873. * @param gradient defines the gradient to remove
  16874. * @returns the current particle system
  16875. */
  16876. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16877. /**
  16878. * Adds a new size gradient
  16879. * @param gradient defines the gradient to use (between 0 and 1)
  16880. * @param factor defines the size factor to affect to the specified gradient
  16881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16882. * @returns the current particle system
  16883. */
  16884. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16885. /**
  16886. * Remove a specific size gradient
  16887. * @param gradient defines the gradient to remove
  16888. * @returns the current particle system
  16889. */
  16890. removeSizeGradient(gradient: number): IParticleSystem;
  16891. /**
  16892. * Adds a new color remap gradient
  16893. * @param gradient defines the gradient to use (between 0 and 1)
  16894. * @param min defines the color remap minimal range
  16895. * @param max defines the color remap maximal range
  16896. * @returns the current particle system
  16897. */
  16898. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16899. /**
  16900. * Remove a specific color remap gradient
  16901. * @param gradient defines the gradient to remove
  16902. * @returns the current particle system
  16903. */
  16904. removeColorRemapGradient(gradient: number): IParticleSystem;
  16905. /**
  16906. * Adds a new alpha remap gradient
  16907. * @param gradient defines the gradient to use (between 0 and 1)
  16908. * @param min defines the alpha remap minimal range
  16909. * @param max defines the alpha remap maximal range
  16910. * @returns the current particle system
  16911. */
  16912. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16913. /**
  16914. * Remove a specific alpha remap gradient
  16915. * @param gradient defines the gradient to remove
  16916. * @returns the current particle system
  16917. */
  16918. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16919. /**
  16920. * Adds a new angular speed gradient
  16921. * @param gradient defines the gradient to use (between 0 and 1)
  16922. * @param factor defines the angular speed to affect to the specified gradient
  16923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16924. * @returns the current particle system
  16925. */
  16926. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16927. /**
  16928. * Remove a specific angular speed gradient
  16929. * @param gradient defines the gradient to remove
  16930. * @returns the current particle system
  16931. */
  16932. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16933. /**
  16934. * Adds a new velocity gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the velocity to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific velocity gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeVelocityGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new limit velocity gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the limit velocity value to affect to the specified gradient
  16951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16952. * @returns the current particle system
  16953. */
  16954. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific limit velocity gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Adds a new drag gradient
  16963. * @param gradient defines the gradient to use (between 0 and 1)
  16964. * @param factor defines the drag value to affect to the specified gradient
  16965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16966. * @returns the current particle system
  16967. */
  16968. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16969. /**
  16970. * Remove a specific drag gradient
  16971. * @param gradient defines the gradient to remove
  16972. * @returns the current particle system
  16973. */
  16974. removeDragGradient(gradient: number): IParticleSystem;
  16975. /**
  16976. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16977. * @param gradient defines the gradient to use (between 0 and 1)
  16978. * @param factor defines the emit rate value to affect to the specified gradient
  16979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16980. * @returns the current particle system
  16981. */
  16982. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16983. /**
  16984. * Remove a specific emit rate gradient
  16985. * @param gradient defines the gradient to remove
  16986. * @returns the current particle system
  16987. */
  16988. removeEmitRateGradient(gradient: number): IParticleSystem;
  16989. /**
  16990. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the start size value to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific start size gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeStartSizeGradient(gradient: number): IParticleSystem;
  17003. private _createRampGradientTexture;
  17004. /**
  17005. * Gets the current list of ramp gradients.
  17006. * You must use addRampGradient and removeRampGradient to udpate this list
  17007. * @returns the list of ramp gradients
  17008. */
  17009. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17010. /**
  17011. * Adds a new ramp gradient used to remap particle colors
  17012. * @param gradient defines the gradient to use (between 0 and 1)
  17013. * @param color defines the color to affect to the specified gradient
  17014. * @returns the current particle system
  17015. */
  17016. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17017. /**
  17018. * Remove a specific ramp gradient
  17019. * @param gradient defines the gradient to remove
  17020. * @returns the current particle system
  17021. */
  17022. removeRampGradient(gradient: number): ParticleSystem;
  17023. /**
  17024. * Adds a new color gradient
  17025. * @param gradient defines the gradient to use (between 0 and 1)
  17026. * @param color1 defines the color to affect to the specified gradient
  17027. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17028. * @returns this particle system
  17029. */
  17030. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17031. /**
  17032. * Remove a specific color gradient
  17033. * @param gradient defines the gradient to remove
  17034. * @returns this particle system
  17035. */
  17036. removeColorGradient(gradient: number): IParticleSystem;
  17037. private _fetchR;
  17038. protected _reset(): void;
  17039. private _resetEffect;
  17040. private _createVertexBuffers;
  17041. private _createIndexBuffer;
  17042. /**
  17043. * Gets the maximum number of particles active at the same time.
  17044. * @returns The max number of active particles.
  17045. */
  17046. getCapacity(): number;
  17047. /**
  17048. * Gets whether there are still active particles in the system.
  17049. * @returns True if it is alive, otherwise false.
  17050. */
  17051. isAlive(): boolean;
  17052. /**
  17053. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17054. * @returns True if it has been started, otherwise false.
  17055. */
  17056. isStarted(): boolean;
  17057. private _prepareSubEmitterInternalArray;
  17058. /**
  17059. * Starts the particle system and begins to emit
  17060. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17061. */
  17062. start(delay?: number): void;
  17063. /**
  17064. * Stops the particle system.
  17065. * @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.
  17066. */
  17067. stop(stopSubEmitters?: boolean): void;
  17068. /**
  17069. * Remove all active particles
  17070. */
  17071. reset(): void;
  17072. /**
  17073. * @hidden (for internal use only)
  17074. */
  17075. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17076. /**
  17077. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17078. * Its lifetime will start back at 0.
  17079. */
  17080. recycleParticle: (particle: Particle) => void;
  17081. private _stopSubEmitters;
  17082. private _createParticle;
  17083. private _removeFromRoot;
  17084. private _emitFromParticle;
  17085. private _update;
  17086. /** @hidden */
  17087. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17088. /** @hidden */
  17089. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17090. /** @hidden */
  17091. private _getEffect;
  17092. /**
  17093. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17094. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17095. */
  17096. animate(preWarmOnly?: boolean): void;
  17097. private _appendParticleVertices;
  17098. /**
  17099. * Rebuilds the particle system.
  17100. */
  17101. rebuild(): void;
  17102. /**
  17103. * Is this system ready to be used/rendered
  17104. * @return true if the system is ready
  17105. */
  17106. isReady(): boolean;
  17107. private _render;
  17108. /**
  17109. * Renders the particle system in its current state.
  17110. * @returns the current number of particles
  17111. */
  17112. render(): number;
  17113. /**
  17114. * Disposes the particle system and free the associated resources
  17115. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17116. */
  17117. dispose(disposeTexture?: boolean): void;
  17118. /**
  17119. * Clones the particle system.
  17120. * @param name The name of the cloned object
  17121. * @param newEmitter The new emitter to use
  17122. * @returns the cloned particle system
  17123. */
  17124. clone(name: string, newEmitter: any): ParticleSystem;
  17125. /**
  17126. * Serializes the particle system to a JSON object.
  17127. * @returns the JSON object
  17128. */
  17129. serialize(): any;
  17130. /** @hidden */
  17131. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17132. /** @hidden */
  17133. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17134. /**
  17135. * Parses a JSON object to create a particle system.
  17136. * @param parsedParticleSystem The JSON object to parse
  17137. * @param scene The scene to create the particle system in
  17138. * @param rootUrl The root url to use to load external dependencies like texture
  17139. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17140. * @returns the Parsed particle system
  17141. */
  17142. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17143. }
  17144. }
  17145. declare module BABYLON {
  17146. /**
  17147. * A particle represents one of the element emitted by a particle system.
  17148. * This is mainly define by its coordinates, direction, velocity and age.
  17149. */
  17150. export class Particle {
  17151. /**
  17152. * The particle system the particle belongs to.
  17153. */
  17154. particleSystem: ParticleSystem;
  17155. private static _Count;
  17156. /**
  17157. * Unique ID of the particle
  17158. */
  17159. id: number;
  17160. /**
  17161. * The world position of the particle in the scene.
  17162. */
  17163. position: Vector3;
  17164. /**
  17165. * The world direction of the particle in the scene.
  17166. */
  17167. direction: Vector3;
  17168. /**
  17169. * The color of the particle.
  17170. */
  17171. color: Color4;
  17172. /**
  17173. * The color change of the particle per step.
  17174. */
  17175. colorStep: Color4;
  17176. /**
  17177. * Defines how long will the life of the particle be.
  17178. */
  17179. lifeTime: number;
  17180. /**
  17181. * The current age of the particle.
  17182. */
  17183. age: number;
  17184. /**
  17185. * The current size of the particle.
  17186. */
  17187. size: number;
  17188. /**
  17189. * The current scale of the particle.
  17190. */
  17191. scale: Vector2;
  17192. /**
  17193. * The current angle of the particle.
  17194. */
  17195. angle: number;
  17196. /**
  17197. * Defines how fast is the angle changing.
  17198. */
  17199. angularSpeed: number;
  17200. /**
  17201. * Defines the cell index used by the particle to be rendered from a sprite.
  17202. */
  17203. cellIndex: number;
  17204. /**
  17205. * The information required to support color remapping
  17206. */
  17207. remapData: Vector4;
  17208. /** @hidden */
  17209. _randomCellOffset?: number;
  17210. /** @hidden */
  17211. _initialDirection: Nullable<Vector3>;
  17212. /** @hidden */
  17213. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17214. /** @hidden */
  17215. _initialStartSpriteCellID: number;
  17216. /** @hidden */
  17217. _initialEndSpriteCellID: number;
  17218. /** @hidden */
  17219. _currentColorGradient: Nullable<ColorGradient>;
  17220. /** @hidden */
  17221. _currentColor1: Color4;
  17222. /** @hidden */
  17223. _currentColor2: Color4;
  17224. /** @hidden */
  17225. _currentSizeGradient: Nullable<FactorGradient>;
  17226. /** @hidden */
  17227. _currentSize1: number;
  17228. /** @hidden */
  17229. _currentSize2: number;
  17230. /** @hidden */
  17231. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17232. /** @hidden */
  17233. _currentAngularSpeed1: number;
  17234. /** @hidden */
  17235. _currentAngularSpeed2: number;
  17236. /** @hidden */
  17237. _currentVelocityGradient: Nullable<FactorGradient>;
  17238. /** @hidden */
  17239. _currentVelocity1: number;
  17240. /** @hidden */
  17241. _currentVelocity2: number;
  17242. /** @hidden */
  17243. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17244. /** @hidden */
  17245. _currentLimitVelocity1: number;
  17246. /** @hidden */
  17247. _currentLimitVelocity2: number;
  17248. /** @hidden */
  17249. _currentDragGradient: Nullable<FactorGradient>;
  17250. /** @hidden */
  17251. _currentDrag1: number;
  17252. /** @hidden */
  17253. _currentDrag2: number;
  17254. /** @hidden */
  17255. _randomNoiseCoordinates1: Vector3;
  17256. /** @hidden */
  17257. _randomNoiseCoordinates2: Vector3;
  17258. /**
  17259. * Creates a new instance Particle
  17260. * @param particleSystem the particle system the particle belongs to
  17261. */
  17262. constructor(
  17263. /**
  17264. * The particle system the particle belongs to.
  17265. */
  17266. particleSystem: ParticleSystem);
  17267. private updateCellInfoFromSystem;
  17268. /**
  17269. * Defines how the sprite cell index is updated for the particle
  17270. */
  17271. updateCellIndex(): void;
  17272. /** @hidden */
  17273. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17274. /** @hidden */
  17275. _inheritParticleInfoToSubEmitters(): void;
  17276. /** @hidden */
  17277. _reset(): void;
  17278. /**
  17279. * Copy the properties of particle to another one.
  17280. * @param other the particle to copy the information to.
  17281. */
  17282. copyTo(other: Particle): void;
  17283. }
  17284. }
  17285. declare module BABYLON {
  17286. /**
  17287. * Particle emitter represents a volume emitting particles.
  17288. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17289. */
  17290. export interface IParticleEmitterType {
  17291. /**
  17292. * Called by the particle System when the direction is computed for the created particle.
  17293. * @param worldMatrix is the world matrix of the particle system
  17294. * @param directionToUpdate is the direction vector to update with the result
  17295. * @param particle is the particle we are computed the direction for
  17296. */
  17297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17298. /**
  17299. * Called by the particle System when the position is computed for the created particle.
  17300. * @param worldMatrix is the world matrix of the particle system
  17301. * @param positionToUpdate is the position vector to update with the result
  17302. * @param particle is the particle we are computed the position for
  17303. */
  17304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17305. /**
  17306. * Clones the current emitter and returns a copy of it
  17307. * @returns the new emitter
  17308. */
  17309. clone(): IParticleEmitterType;
  17310. /**
  17311. * Called by the GPUParticleSystem to setup the update shader
  17312. * @param effect defines the update shader
  17313. */
  17314. applyToShader(effect: Effect): void;
  17315. /**
  17316. * Returns a string to use to update the GPU particles update shader
  17317. * @returns the effect defines string
  17318. */
  17319. getEffectDefines(): string;
  17320. /**
  17321. * Returns a string representing the class name
  17322. * @returns a string containing the class name
  17323. */
  17324. getClassName(): string;
  17325. /**
  17326. * Serializes the particle system to a JSON object.
  17327. * @returns the JSON object
  17328. */
  17329. serialize(): any;
  17330. /**
  17331. * Parse properties from a JSON object
  17332. * @param serializationObject defines the JSON object
  17333. */
  17334. parse(serializationObject: any): void;
  17335. }
  17336. }
  17337. declare module BABYLON {
  17338. /**
  17339. * Particle emitter emitting particles from the inside of a box.
  17340. * It emits the particles randomly between 2 given directions.
  17341. */
  17342. export class BoxParticleEmitter implements IParticleEmitterType {
  17343. /**
  17344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17345. */
  17346. direction1: Vector3;
  17347. /**
  17348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17349. */
  17350. direction2: Vector3;
  17351. /**
  17352. * 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.
  17353. */
  17354. minEmitBox: Vector3;
  17355. /**
  17356. * 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.
  17357. */
  17358. maxEmitBox: Vector3;
  17359. /**
  17360. * Creates a new instance BoxParticleEmitter
  17361. */
  17362. constructor();
  17363. /**
  17364. * Called by the particle System when the direction is computed for the created particle.
  17365. * @param worldMatrix is the world matrix of the particle system
  17366. * @param directionToUpdate is the direction vector to update with the result
  17367. * @param particle is the particle we are computed the direction for
  17368. */
  17369. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17370. /**
  17371. * Called by the particle System when the position is computed for the created particle.
  17372. * @param worldMatrix is the world matrix of the particle system
  17373. * @param positionToUpdate is the position vector to update with the result
  17374. * @param particle is the particle we are computed the position for
  17375. */
  17376. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17377. /**
  17378. * Clones the current emitter and returns a copy of it
  17379. * @returns the new emitter
  17380. */
  17381. clone(): BoxParticleEmitter;
  17382. /**
  17383. * Called by the GPUParticleSystem to setup the update shader
  17384. * @param effect defines the update shader
  17385. */
  17386. applyToShader(effect: Effect): void;
  17387. /**
  17388. * Returns a string to use to update the GPU particles update shader
  17389. * @returns a string containng the defines string
  17390. */
  17391. getEffectDefines(): string;
  17392. /**
  17393. * Returns the string "BoxParticleEmitter"
  17394. * @returns a string containing the class name
  17395. */
  17396. getClassName(): string;
  17397. /**
  17398. * Serializes the particle system to a JSON object.
  17399. * @returns the JSON object
  17400. */
  17401. serialize(): any;
  17402. /**
  17403. * Parse properties from a JSON object
  17404. * @param serializationObject defines the JSON object
  17405. */
  17406. parse(serializationObject: any): void;
  17407. }
  17408. }
  17409. declare module BABYLON {
  17410. /**
  17411. * Particle emitter emitting particles from the inside of a cone.
  17412. * It emits the particles alongside the cone volume from the base to the particle.
  17413. * The emission direction might be randomized.
  17414. */
  17415. export class ConeParticleEmitter implements IParticleEmitterType {
  17416. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17417. directionRandomizer: number;
  17418. private _radius;
  17419. private _angle;
  17420. private _height;
  17421. /**
  17422. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17423. */
  17424. radiusRange: number;
  17425. /**
  17426. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17427. */
  17428. heightRange: number;
  17429. /**
  17430. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17431. */
  17432. emitFromSpawnPointOnly: boolean;
  17433. /**
  17434. * Gets or sets the radius of the emission cone
  17435. */
  17436. radius: number;
  17437. /**
  17438. * Gets or sets the angle of the emission cone
  17439. */
  17440. angle: number;
  17441. private _buildHeight;
  17442. /**
  17443. * Creates a new instance ConeParticleEmitter
  17444. * @param radius the radius of the emission cone (1 by default)
  17445. * @param angle the cone base angle (PI by default)
  17446. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17447. */
  17448. constructor(radius?: number, angle?: number,
  17449. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17450. directionRandomizer?: number);
  17451. /**
  17452. * Called by the particle System when the direction is computed for the created particle.
  17453. * @param worldMatrix is the world matrix of the particle system
  17454. * @param directionToUpdate is the direction vector to update with the result
  17455. * @param particle is the particle we are computed the direction for
  17456. */
  17457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17458. /**
  17459. * Called by the particle System when the position is computed for the created particle.
  17460. * @param worldMatrix is the world matrix of the particle system
  17461. * @param positionToUpdate is the position vector to update with the result
  17462. * @param particle is the particle we are computed the position for
  17463. */
  17464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17465. /**
  17466. * Clones the current emitter and returns a copy of it
  17467. * @returns the new emitter
  17468. */
  17469. clone(): ConeParticleEmitter;
  17470. /**
  17471. * Called by the GPUParticleSystem to setup the update shader
  17472. * @param effect defines the update shader
  17473. */
  17474. applyToShader(effect: Effect): void;
  17475. /**
  17476. * Returns a string to use to update the GPU particles update shader
  17477. * @returns a string containng the defines string
  17478. */
  17479. getEffectDefines(): string;
  17480. /**
  17481. * Returns the string "ConeParticleEmitter"
  17482. * @returns a string containing the class name
  17483. */
  17484. getClassName(): string;
  17485. /**
  17486. * Serializes the particle system to a JSON object.
  17487. * @returns the JSON object
  17488. */
  17489. serialize(): any;
  17490. /**
  17491. * Parse properties from a JSON object
  17492. * @param serializationObject defines the JSON object
  17493. */
  17494. parse(serializationObject: any): void;
  17495. }
  17496. }
  17497. declare module BABYLON {
  17498. /**
  17499. * Particle emitter emitting particles from the inside of a cylinder.
  17500. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17501. */
  17502. export class CylinderParticleEmitter implements IParticleEmitterType {
  17503. /**
  17504. * The radius of the emission cylinder.
  17505. */
  17506. radius: number;
  17507. /**
  17508. * The height of the emission cylinder.
  17509. */
  17510. height: number;
  17511. /**
  17512. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17513. */
  17514. radiusRange: number;
  17515. /**
  17516. * How much to randomize the particle direction [0-1].
  17517. */
  17518. directionRandomizer: number;
  17519. /**
  17520. * Creates a new instance CylinderParticleEmitter
  17521. * @param radius the radius of the emission cylinder (1 by default)
  17522. * @param height the height of the emission cylinder (1 by default)
  17523. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17524. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17525. */
  17526. constructor(
  17527. /**
  17528. * The radius of the emission cylinder.
  17529. */
  17530. radius?: number,
  17531. /**
  17532. * The height of the emission cylinder.
  17533. */
  17534. height?: number,
  17535. /**
  17536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17537. */
  17538. radiusRange?: number,
  17539. /**
  17540. * How much to randomize the particle direction [0-1].
  17541. */
  17542. directionRandomizer?: number);
  17543. /**
  17544. * Called by the particle System when the direction is computed for the created particle.
  17545. * @param worldMatrix is the world matrix of the particle system
  17546. * @param directionToUpdate is the direction vector to update with the result
  17547. * @param particle is the particle we are computed the direction for
  17548. */
  17549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17550. /**
  17551. * Called by the particle System when the position is computed for the created particle.
  17552. * @param worldMatrix is the world matrix of the particle system
  17553. * @param positionToUpdate is the position vector to update with the result
  17554. * @param particle is the particle we are computed the position for
  17555. */
  17556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17557. /**
  17558. * Clones the current emitter and returns a copy of it
  17559. * @returns the new emitter
  17560. */
  17561. clone(): CylinderParticleEmitter;
  17562. /**
  17563. * Called by the GPUParticleSystem to setup the update shader
  17564. * @param effect defines the update shader
  17565. */
  17566. applyToShader(effect: Effect): void;
  17567. /**
  17568. * Returns a string to use to update the GPU particles update shader
  17569. * @returns a string containng the defines string
  17570. */
  17571. getEffectDefines(): string;
  17572. /**
  17573. * Returns the string "CylinderParticleEmitter"
  17574. * @returns a string containing the class name
  17575. */
  17576. getClassName(): string;
  17577. /**
  17578. * Serializes the particle system to a JSON object.
  17579. * @returns the JSON object
  17580. */
  17581. serialize(): any;
  17582. /**
  17583. * Parse properties from a JSON object
  17584. * @param serializationObject defines the JSON object
  17585. */
  17586. parse(serializationObject: any): void;
  17587. }
  17588. /**
  17589. * Particle emitter emitting particles from the inside of a cylinder.
  17590. * It emits the particles randomly between two vectors.
  17591. */
  17592. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17593. /**
  17594. * The min limit of the emission direction.
  17595. */
  17596. direction1: Vector3;
  17597. /**
  17598. * The max limit of the emission direction.
  17599. */
  17600. direction2: Vector3;
  17601. /**
  17602. * Creates a new instance CylinderDirectedParticleEmitter
  17603. * @param radius the radius of the emission cylinder (1 by default)
  17604. * @param height the height of the emission cylinder (1 by default)
  17605. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17606. * @param direction1 the min limit of the emission direction (up vector by default)
  17607. * @param direction2 the max limit of the emission direction (up vector by default)
  17608. */
  17609. constructor(radius?: number, height?: number, radiusRange?: number,
  17610. /**
  17611. * The min limit of the emission direction.
  17612. */
  17613. direction1?: Vector3,
  17614. /**
  17615. * The max limit of the emission direction.
  17616. */
  17617. direction2?: Vector3);
  17618. /**
  17619. * Called by the particle System when the direction is computed for the created particle.
  17620. * @param worldMatrix is the world matrix of the particle system
  17621. * @param directionToUpdate is the direction vector to update with the result
  17622. * @param particle is the particle we are computed the direction for
  17623. */
  17624. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17625. /**
  17626. * Clones the current emitter and returns a copy of it
  17627. * @returns the new emitter
  17628. */
  17629. clone(): CylinderDirectedParticleEmitter;
  17630. /**
  17631. * Called by the GPUParticleSystem to setup the update shader
  17632. * @param effect defines the update shader
  17633. */
  17634. applyToShader(effect: Effect): void;
  17635. /**
  17636. * Returns a string to use to update the GPU particles update shader
  17637. * @returns a string containng the defines string
  17638. */
  17639. getEffectDefines(): string;
  17640. /**
  17641. * Returns the string "CylinderDirectedParticleEmitter"
  17642. * @returns a string containing the class name
  17643. */
  17644. getClassName(): string;
  17645. /**
  17646. * Serializes the particle system to a JSON object.
  17647. * @returns the JSON object
  17648. */
  17649. serialize(): any;
  17650. /**
  17651. * Parse properties from a JSON object
  17652. * @param serializationObject defines the JSON object
  17653. */
  17654. parse(serializationObject: any): void;
  17655. }
  17656. }
  17657. declare module BABYLON {
  17658. /**
  17659. * Particle emitter emitting particles from the inside of a hemisphere.
  17660. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17661. */
  17662. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17663. /**
  17664. * The radius of the emission hemisphere.
  17665. */
  17666. radius: number;
  17667. /**
  17668. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17669. */
  17670. radiusRange: number;
  17671. /**
  17672. * How much to randomize the particle direction [0-1].
  17673. */
  17674. directionRandomizer: number;
  17675. /**
  17676. * Creates a new instance HemisphericParticleEmitter
  17677. * @param radius the radius of the emission hemisphere (1 by default)
  17678. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17679. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17680. */
  17681. constructor(
  17682. /**
  17683. * The radius of the emission hemisphere.
  17684. */
  17685. radius?: number,
  17686. /**
  17687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17688. */
  17689. radiusRange?: number,
  17690. /**
  17691. * How much to randomize the particle direction [0-1].
  17692. */
  17693. directionRandomizer?: number);
  17694. /**
  17695. * Called by the particle System when the direction is computed for the created particle.
  17696. * @param worldMatrix is the world matrix of the particle system
  17697. * @param directionToUpdate is the direction vector to update with the result
  17698. * @param particle is the particle we are computed the direction for
  17699. */
  17700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17701. /**
  17702. * Called by the particle System when the position is computed for the created particle.
  17703. * @param worldMatrix is the world matrix of the particle system
  17704. * @param positionToUpdate is the position vector to update with the result
  17705. * @param particle is the particle we are computed the position for
  17706. */
  17707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17708. /**
  17709. * Clones the current emitter and returns a copy of it
  17710. * @returns the new emitter
  17711. */
  17712. clone(): HemisphericParticleEmitter;
  17713. /**
  17714. * Called by the GPUParticleSystem to setup the update shader
  17715. * @param effect defines the update shader
  17716. */
  17717. applyToShader(effect: Effect): void;
  17718. /**
  17719. * Returns a string to use to update the GPU particles update shader
  17720. * @returns a string containng the defines string
  17721. */
  17722. getEffectDefines(): string;
  17723. /**
  17724. * Returns the string "HemisphericParticleEmitter"
  17725. * @returns a string containing the class name
  17726. */
  17727. getClassName(): string;
  17728. /**
  17729. * Serializes the particle system to a JSON object.
  17730. * @returns the JSON object
  17731. */
  17732. serialize(): any;
  17733. /**
  17734. * Parse properties from a JSON object
  17735. * @param serializationObject defines the JSON object
  17736. */
  17737. parse(serializationObject: any): void;
  17738. }
  17739. }
  17740. declare module BABYLON {
  17741. /**
  17742. * Particle emitter emitting particles from a point.
  17743. * It emits the particles randomly between 2 given directions.
  17744. */
  17745. export class PointParticleEmitter implements IParticleEmitterType {
  17746. /**
  17747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17748. */
  17749. direction1: Vector3;
  17750. /**
  17751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17752. */
  17753. direction2: Vector3;
  17754. /**
  17755. * Creates a new instance PointParticleEmitter
  17756. */
  17757. constructor();
  17758. /**
  17759. * Called by the particle System when the direction is computed for the created particle.
  17760. * @param worldMatrix is the world matrix of the particle system
  17761. * @param directionToUpdate is the direction vector to update with the result
  17762. * @param particle is the particle we are computed the direction for
  17763. */
  17764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17765. /**
  17766. * Called by the particle System when the position is computed for the created particle.
  17767. * @param worldMatrix is the world matrix of the particle system
  17768. * @param positionToUpdate is the position vector to update with the result
  17769. * @param particle is the particle we are computed the position for
  17770. */
  17771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17772. /**
  17773. * Clones the current emitter and returns a copy of it
  17774. * @returns the new emitter
  17775. */
  17776. clone(): PointParticleEmitter;
  17777. /**
  17778. * Called by the GPUParticleSystem to setup the update shader
  17779. * @param effect defines the update shader
  17780. */
  17781. applyToShader(effect: Effect): void;
  17782. /**
  17783. * Returns a string to use to update the GPU particles update shader
  17784. * @returns a string containng the defines string
  17785. */
  17786. getEffectDefines(): string;
  17787. /**
  17788. * Returns the string "PointParticleEmitter"
  17789. * @returns a string containing the class name
  17790. */
  17791. getClassName(): string;
  17792. /**
  17793. * Serializes the particle system to a JSON object.
  17794. * @returns the JSON object
  17795. */
  17796. serialize(): any;
  17797. /**
  17798. * Parse properties from a JSON object
  17799. * @param serializationObject defines the JSON object
  17800. */
  17801. parse(serializationObject: any): void;
  17802. }
  17803. }
  17804. declare module BABYLON {
  17805. /**
  17806. * Particle emitter emitting particles from the inside of a sphere.
  17807. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17808. */
  17809. export class SphereParticleEmitter implements IParticleEmitterType {
  17810. /**
  17811. * The radius of the emission sphere.
  17812. */
  17813. radius: number;
  17814. /**
  17815. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17816. */
  17817. radiusRange: number;
  17818. /**
  17819. * How much to randomize the particle direction [0-1].
  17820. */
  17821. directionRandomizer: number;
  17822. /**
  17823. * Creates a new instance SphereParticleEmitter
  17824. * @param radius the radius of the emission sphere (1 by default)
  17825. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17826. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17827. */
  17828. constructor(
  17829. /**
  17830. * The radius of the emission sphere.
  17831. */
  17832. radius?: number,
  17833. /**
  17834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17835. */
  17836. radiusRange?: number,
  17837. /**
  17838. * How much to randomize the particle direction [0-1].
  17839. */
  17840. directionRandomizer?: number);
  17841. /**
  17842. * Called by the particle System when the direction is computed for the created particle.
  17843. * @param worldMatrix is the world matrix of the particle system
  17844. * @param directionToUpdate is the direction vector to update with the result
  17845. * @param particle is the particle we are computed the direction for
  17846. */
  17847. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17848. /**
  17849. * Called by the particle System when the position is computed for the created particle.
  17850. * @param worldMatrix is the world matrix of the particle system
  17851. * @param positionToUpdate is the position vector to update with the result
  17852. * @param particle is the particle we are computed the position for
  17853. */
  17854. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17855. /**
  17856. * Clones the current emitter and returns a copy of it
  17857. * @returns the new emitter
  17858. */
  17859. clone(): SphereParticleEmitter;
  17860. /**
  17861. * Called by the GPUParticleSystem to setup the update shader
  17862. * @param effect defines the update shader
  17863. */
  17864. applyToShader(effect: Effect): void;
  17865. /**
  17866. * Returns a string to use to update the GPU particles update shader
  17867. * @returns a string containng the defines string
  17868. */
  17869. getEffectDefines(): string;
  17870. /**
  17871. * Returns the string "SphereParticleEmitter"
  17872. * @returns a string containing the class name
  17873. */
  17874. getClassName(): string;
  17875. /**
  17876. * Serializes the particle system to a JSON object.
  17877. * @returns the JSON object
  17878. */
  17879. serialize(): any;
  17880. /**
  17881. * Parse properties from a JSON object
  17882. * @param serializationObject defines the JSON object
  17883. */
  17884. parse(serializationObject: any): void;
  17885. }
  17886. /**
  17887. * Particle emitter emitting particles from the inside of a sphere.
  17888. * It emits the particles randomly between two vectors.
  17889. */
  17890. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17891. /**
  17892. * The min limit of the emission direction.
  17893. */
  17894. direction1: Vector3;
  17895. /**
  17896. * The max limit of the emission direction.
  17897. */
  17898. direction2: Vector3;
  17899. /**
  17900. * Creates a new instance SphereDirectedParticleEmitter
  17901. * @param radius the radius of the emission sphere (1 by default)
  17902. * @param direction1 the min limit of the emission direction (up vector by default)
  17903. * @param direction2 the max limit of the emission direction (up vector by default)
  17904. */
  17905. constructor(radius?: number,
  17906. /**
  17907. * The min limit of the emission direction.
  17908. */
  17909. direction1?: Vector3,
  17910. /**
  17911. * The max limit of the emission direction.
  17912. */
  17913. direction2?: Vector3);
  17914. /**
  17915. * Called by the particle System when the direction is computed for the created particle.
  17916. * @param worldMatrix is the world matrix of the particle system
  17917. * @param directionToUpdate is the direction vector to update with the result
  17918. * @param particle is the particle we are computed the direction for
  17919. */
  17920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17921. /**
  17922. * Clones the current emitter and returns a copy of it
  17923. * @returns the new emitter
  17924. */
  17925. clone(): SphereDirectedParticleEmitter;
  17926. /**
  17927. * Called by the GPUParticleSystem to setup the update shader
  17928. * @param effect defines the update shader
  17929. */
  17930. applyToShader(effect: Effect): void;
  17931. /**
  17932. * Returns a string to use to update the GPU particles update shader
  17933. * @returns a string containng the defines string
  17934. */
  17935. getEffectDefines(): string;
  17936. /**
  17937. * Returns the string "SphereDirectedParticleEmitter"
  17938. * @returns a string containing the class name
  17939. */
  17940. getClassName(): string;
  17941. /**
  17942. * Serializes the particle system to a JSON object.
  17943. * @returns the JSON object
  17944. */
  17945. serialize(): any;
  17946. /**
  17947. * Parse properties from a JSON object
  17948. * @param serializationObject defines the JSON object
  17949. */
  17950. parse(serializationObject: any): void;
  17951. }
  17952. }
  17953. declare module BABYLON {
  17954. /**
  17955. * Interface representing a particle system in Babylon.js.
  17956. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17957. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17958. */
  17959. export interface IParticleSystem {
  17960. /**
  17961. * List of animations used by the particle system.
  17962. */
  17963. animations: Animation[];
  17964. /**
  17965. * The id of the Particle system.
  17966. */
  17967. id: string;
  17968. /**
  17969. * The name of the Particle system.
  17970. */
  17971. name: string;
  17972. /**
  17973. * The emitter represents the Mesh or position we are attaching the particle system to.
  17974. */
  17975. emitter: Nullable<AbstractMesh | Vector3>;
  17976. /**
  17977. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17978. */
  17979. isBillboardBased: boolean;
  17980. /**
  17981. * The rendering group used by the Particle system to chose when to render.
  17982. */
  17983. renderingGroupId: number;
  17984. /**
  17985. * The layer mask we are rendering the particles through.
  17986. */
  17987. layerMask: number;
  17988. /**
  17989. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17990. */
  17991. updateSpeed: number;
  17992. /**
  17993. * The amount of time the particle system is running (depends of the overall update speed).
  17994. */
  17995. targetStopDuration: number;
  17996. /**
  17997. * The texture used to render each particle. (this can be a spritesheet)
  17998. */
  17999. particleTexture: Nullable<Texture>;
  18000. /**
  18001. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18002. */
  18003. blendMode: number;
  18004. /**
  18005. * Minimum life time of emitting particles.
  18006. */
  18007. minLifeTime: number;
  18008. /**
  18009. * Maximum life time of emitting particles.
  18010. */
  18011. maxLifeTime: number;
  18012. /**
  18013. * Minimum Size of emitting particles.
  18014. */
  18015. minSize: number;
  18016. /**
  18017. * Maximum Size of emitting particles.
  18018. */
  18019. maxSize: number;
  18020. /**
  18021. * Minimum scale of emitting particles on X axis.
  18022. */
  18023. minScaleX: number;
  18024. /**
  18025. * Maximum scale of emitting particles on X axis.
  18026. */
  18027. maxScaleX: number;
  18028. /**
  18029. * Minimum scale of emitting particles on Y axis.
  18030. */
  18031. minScaleY: number;
  18032. /**
  18033. * Maximum scale of emitting particles on Y axis.
  18034. */
  18035. maxScaleY: number;
  18036. /**
  18037. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18038. */
  18039. color1: Color4;
  18040. /**
  18041. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18042. */
  18043. color2: Color4;
  18044. /**
  18045. * Color the particle will have at the end of its lifetime.
  18046. */
  18047. colorDead: Color4;
  18048. /**
  18049. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18050. */
  18051. emitRate: number;
  18052. /**
  18053. * You can use gravity if you want to give an orientation to your particles.
  18054. */
  18055. gravity: Vector3;
  18056. /**
  18057. * Minimum power of emitting particles.
  18058. */
  18059. minEmitPower: number;
  18060. /**
  18061. * Maximum power of emitting particles.
  18062. */
  18063. maxEmitPower: number;
  18064. /**
  18065. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18066. */
  18067. minAngularSpeed: number;
  18068. /**
  18069. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18070. */
  18071. maxAngularSpeed: number;
  18072. /**
  18073. * Gets or sets the minimal initial rotation in radians.
  18074. */
  18075. minInitialRotation: number;
  18076. /**
  18077. * Gets or sets the maximal initial rotation in radians.
  18078. */
  18079. maxInitialRotation: number;
  18080. /**
  18081. * The particle emitter type defines the emitter used by the particle system.
  18082. * It can be for example box, sphere, or cone...
  18083. */
  18084. particleEmitterType: Nullable<IParticleEmitterType>;
  18085. /**
  18086. * Defines the delay in milliseconds before starting the system (0 by default)
  18087. */
  18088. startDelay: number;
  18089. /**
  18090. * 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
  18091. */
  18092. preWarmCycles: number;
  18093. /**
  18094. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18095. */
  18096. preWarmStepOffset: number;
  18097. /**
  18098. * 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)
  18099. */
  18100. spriteCellChangeSpeed: number;
  18101. /**
  18102. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18103. */
  18104. startSpriteCellID: number;
  18105. /**
  18106. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18107. */
  18108. endSpriteCellID: number;
  18109. /**
  18110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18111. */
  18112. spriteCellWidth: number;
  18113. /**
  18114. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18115. */
  18116. spriteCellHeight: number;
  18117. /**
  18118. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18119. */
  18120. spriteRandomStartCell: boolean;
  18121. /**
  18122. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18123. */
  18124. isAnimationSheetEnabled: boolean;
  18125. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18126. translationPivot: Vector2;
  18127. /**
  18128. * Gets or sets a texture used to add random noise to particle positions
  18129. */
  18130. noiseTexture: Nullable<BaseTexture>;
  18131. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18132. noiseStrength: Vector3;
  18133. /**
  18134. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18135. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18136. */
  18137. billboardMode: number;
  18138. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18139. limitVelocityDamping: number;
  18140. /**
  18141. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18142. */
  18143. beginAnimationOnStart: boolean;
  18144. /**
  18145. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18146. */
  18147. beginAnimationFrom: number;
  18148. /**
  18149. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18150. */
  18151. beginAnimationTo: number;
  18152. /**
  18153. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18154. */
  18155. beginAnimationLoop: boolean;
  18156. /**
  18157. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18158. */
  18159. disposeOnStop: boolean;
  18160. /**
  18161. * Gets the maximum number of particles active at the same time.
  18162. * @returns The max number of active particles.
  18163. */
  18164. getCapacity(): number;
  18165. /**
  18166. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18167. * @returns True if it has been started, otherwise false.
  18168. */
  18169. isStarted(): boolean;
  18170. /**
  18171. * Animates the particle system for this frame.
  18172. */
  18173. animate(): void;
  18174. /**
  18175. * Renders the particle system in its current state.
  18176. * @returns the current number of particles
  18177. */
  18178. render(): number;
  18179. /**
  18180. * Dispose the particle system and frees its associated resources.
  18181. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18182. */
  18183. dispose(disposeTexture?: boolean): void;
  18184. /**
  18185. * Clones the particle system.
  18186. * @param name The name of the cloned object
  18187. * @param newEmitter The new emitter to use
  18188. * @returns the cloned particle system
  18189. */
  18190. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18191. /**
  18192. * Serializes the particle system to a JSON object.
  18193. * @returns the JSON object
  18194. */
  18195. serialize(): any;
  18196. /**
  18197. * Rebuild the particle system
  18198. */
  18199. rebuild(): void;
  18200. /**
  18201. * Starts the particle system and begins to emit
  18202. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18203. */
  18204. start(delay?: number): void;
  18205. /**
  18206. * Stops the particle system.
  18207. */
  18208. stop(): void;
  18209. /**
  18210. * Remove all active particles
  18211. */
  18212. reset(): void;
  18213. /**
  18214. * Is this system ready to be used/rendered
  18215. * @return true if the system is ready
  18216. */
  18217. isReady(): boolean;
  18218. /**
  18219. * Adds a new color gradient
  18220. * @param gradient defines the gradient to use (between 0 and 1)
  18221. * @param color1 defines the color to affect to the specified gradient
  18222. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18223. * @returns the current particle system
  18224. */
  18225. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18226. /**
  18227. * Remove a specific color gradient
  18228. * @param gradient defines the gradient to remove
  18229. * @returns the current particle system
  18230. */
  18231. removeColorGradient(gradient: number): IParticleSystem;
  18232. /**
  18233. * Adds a new size gradient
  18234. * @param gradient defines the gradient to use (between 0 and 1)
  18235. * @param factor defines the size factor to affect to the specified gradient
  18236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18237. * @returns the current particle system
  18238. */
  18239. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18240. /**
  18241. * Remove a specific size gradient
  18242. * @param gradient defines the gradient to remove
  18243. * @returns the current particle system
  18244. */
  18245. removeSizeGradient(gradient: number): IParticleSystem;
  18246. /**
  18247. * Gets the current list of color gradients.
  18248. * You must use addColorGradient and removeColorGradient to udpate this list
  18249. * @returns the list of color gradients
  18250. */
  18251. getColorGradients(): Nullable<Array<ColorGradient>>;
  18252. /**
  18253. * Gets the current list of size gradients.
  18254. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18255. * @returns the list of size gradients
  18256. */
  18257. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18258. /**
  18259. * Gets the current list of angular speed gradients.
  18260. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18261. * @returns the list of angular speed gradients
  18262. */
  18263. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18264. /**
  18265. * Adds a new angular speed gradient
  18266. * @param gradient defines the gradient to use (between 0 and 1)
  18267. * @param factor defines the angular speed to affect to the specified gradient
  18268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18269. * @returns the current particle system
  18270. */
  18271. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18272. /**
  18273. * Remove a specific angular speed gradient
  18274. * @param gradient defines the gradient to remove
  18275. * @returns the current particle system
  18276. */
  18277. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18278. /**
  18279. * Gets the current list of velocity gradients.
  18280. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18281. * @returns the list of velocity gradients
  18282. */
  18283. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18284. /**
  18285. * Adds a new velocity gradient
  18286. * @param gradient defines the gradient to use (between 0 and 1)
  18287. * @param factor defines the velocity to affect to the specified gradient
  18288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18289. * @returns the current particle system
  18290. */
  18291. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18292. /**
  18293. * Remove a specific velocity gradient
  18294. * @param gradient defines the gradient to remove
  18295. * @returns the current particle system
  18296. */
  18297. removeVelocityGradient(gradient: number): IParticleSystem;
  18298. /**
  18299. * Gets the current list of limit velocity gradients.
  18300. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18301. * @returns the list of limit velocity gradients
  18302. */
  18303. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18304. /**
  18305. * Adds a new limit velocity gradient
  18306. * @param gradient defines the gradient to use (between 0 and 1)
  18307. * @param factor defines the limit velocity to affect to the specified gradient
  18308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18309. * @returns the current particle system
  18310. */
  18311. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18312. /**
  18313. * Remove a specific limit velocity gradient
  18314. * @param gradient defines the gradient to remove
  18315. * @returns the current particle system
  18316. */
  18317. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18318. /**
  18319. * Adds a new drag gradient
  18320. * @param gradient defines the gradient to use (between 0 and 1)
  18321. * @param factor defines the drag to affect to the specified gradient
  18322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18323. * @returns the current particle system
  18324. */
  18325. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18326. /**
  18327. * Remove a specific drag gradient
  18328. * @param gradient defines the gradient to remove
  18329. * @returns the current particle system
  18330. */
  18331. removeDragGradient(gradient: number): IParticleSystem;
  18332. /**
  18333. * Gets the current list of drag gradients.
  18334. * You must use addDragGradient and removeDragGradient to udpate this list
  18335. * @returns the list of drag gradients
  18336. */
  18337. getDragGradients(): Nullable<Array<FactorGradient>>;
  18338. /**
  18339. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18340. * @param gradient defines the gradient to use (between 0 and 1)
  18341. * @param factor defines the emit rate to affect to the specified gradient
  18342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18343. * @returns the current particle system
  18344. */
  18345. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18346. /**
  18347. * Remove a specific emit rate gradient
  18348. * @param gradient defines the gradient to remove
  18349. * @returns the current particle system
  18350. */
  18351. removeEmitRateGradient(gradient: number): IParticleSystem;
  18352. /**
  18353. * Gets the current list of emit rate gradients.
  18354. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18355. * @returns the list of emit rate gradients
  18356. */
  18357. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18358. /**
  18359. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18360. * @param gradient defines the gradient to use (between 0 and 1)
  18361. * @param factor defines the start size to affect to the specified gradient
  18362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18363. * @returns the current particle system
  18364. */
  18365. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18366. /**
  18367. * Remove a specific start size gradient
  18368. * @param gradient defines the gradient to remove
  18369. * @returns the current particle system
  18370. */
  18371. removeStartSizeGradient(gradient: number): IParticleSystem;
  18372. /**
  18373. * Gets the current list of start size gradients.
  18374. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18375. * @returns the list of start size gradients
  18376. */
  18377. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18378. /**
  18379. * Adds a new life time gradient
  18380. * @param gradient defines the gradient to use (between 0 and 1)
  18381. * @param factor defines the life time factor to affect to the specified gradient
  18382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18383. * @returns the current particle system
  18384. */
  18385. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18386. /**
  18387. * Remove a specific life time gradient
  18388. * @param gradient defines the gradient to remove
  18389. * @returns the current particle system
  18390. */
  18391. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18392. /**
  18393. * Gets the current list of life time gradients.
  18394. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18395. * @returns the list of life time gradients
  18396. */
  18397. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18398. /**
  18399. * Gets the current list of color gradients.
  18400. * You must use addColorGradient and removeColorGradient to udpate this list
  18401. * @returns the list of color gradients
  18402. */
  18403. getColorGradients(): Nullable<Array<ColorGradient>>;
  18404. /**
  18405. * Adds a new ramp gradient used to remap particle colors
  18406. * @param gradient defines the gradient to use (between 0 and 1)
  18407. * @param color defines the color to affect to the specified gradient
  18408. * @returns the current particle system
  18409. */
  18410. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18411. /**
  18412. * Gets the current list of ramp gradients.
  18413. * You must use addRampGradient and removeRampGradient to udpate this list
  18414. * @returns the list of ramp gradients
  18415. */
  18416. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18417. /** Gets or sets a boolean indicating that ramp gradients must be used
  18418. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18419. */
  18420. useRampGradients: boolean;
  18421. /**
  18422. * Adds a new color remap gradient
  18423. * @param gradient defines the gradient to use (between 0 and 1)
  18424. * @param min defines the color remap minimal range
  18425. * @param max defines the color remap maximal range
  18426. * @returns the current particle system
  18427. */
  18428. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18429. /**
  18430. * Gets the current list of color remap gradients.
  18431. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18432. * @returns the list of color remap gradients
  18433. */
  18434. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18435. /**
  18436. * Adds a new alpha remap gradient
  18437. * @param gradient defines the gradient to use (between 0 and 1)
  18438. * @param min defines the alpha remap minimal range
  18439. * @param max defines the alpha remap maximal range
  18440. * @returns the current particle system
  18441. */
  18442. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18443. /**
  18444. * Gets the current list of alpha remap gradients.
  18445. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18446. * @returns the list of alpha remap gradients
  18447. */
  18448. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18449. /**
  18450. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18453. * @returns the emitter
  18454. */
  18455. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18456. /**
  18457. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18458. * @param radius The radius of the hemisphere to emit from
  18459. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18460. * @returns the emitter
  18461. */
  18462. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18463. /**
  18464. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18465. * @param radius The radius of the sphere to emit from
  18466. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18467. * @returns the emitter
  18468. */
  18469. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18470. /**
  18471. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18472. * @param radius The radius of the sphere to emit from
  18473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18475. * @returns the emitter
  18476. */
  18477. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18478. /**
  18479. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18480. * @param radius The radius of the emission cylinder
  18481. * @param height The height of the emission cylinder
  18482. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18483. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18484. * @returns the emitter
  18485. */
  18486. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18487. /**
  18488. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18489. * @param radius The radius of the cylinder to emit from
  18490. * @param height The height of the emission cylinder
  18491. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18494. * @returns the emitter
  18495. */
  18496. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18497. /**
  18498. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18499. * @param radius The radius of the cone to emit from
  18500. * @param angle The base angle of the cone
  18501. * @returns the emitter
  18502. */
  18503. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18504. /**
  18505. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18508. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18509. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18510. * @returns the emitter
  18511. */
  18512. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18513. /**
  18514. * Get hosting scene
  18515. * @returns the scene
  18516. */
  18517. getScene(): Scene;
  18518. }
  18519. }
  18520. declare module BABYLON {
  18521. /**
  18522. * Creates an instance based on a source mesh.
  18523. */
  18524. export class InstancedMesh extends AbstractMesh {
  18525. private _sourceMesh;
  18526. private _currentLOD;
  18527. /** @hidden */
  18528. _indexInSourceMeshInstanceArray: number;
  18529. constructor(name: string, source: Mesh);
  18530. /**
  18531. * Returns the string "InstancedMesh".
  18532. */
  18533. getClassName(): string;
  18534. /** Gets the list of lights affecting that mesh */
  18535. readonly lightSources: Light[];
  18536. _resyncLightSources(): void;
  18537. _resyncLighSource(light: Light): void;
  18538. _removeLightSource(light: Light): void;
  18539. /**
  18540. * If the source mesh receives shadows
  18541. */
  18542. readonly receiveShadows: boolean;
  18543. /**
  18544. * The material of the source mesh
  18545. */
  18546. readonly material: Nullable<Material>;
  18547. /**
  18548. * Visibility of the source mesh
  18549. */
  18550. readonly visibility: number;
  18551. /**
  18552. * Skeleton of the source mesh
  18553. */
  18554. readonly skeleton: Nullable<Skeleton>;
  18555. /**
  18556. * Rendering ground id of the source mesh
  18557. */
  18558. renderingGroupId: number;
  18559. /**
  18560. * Returns the total number of vertices (integer).
  18561. */
  18562. getTotalVertices(): number;
  18563. /**
  18564. * Returns a positive integer : the total number of indices in this mesh geometry.
  18565. * @returns the numner of indices or zero if the mesh has no geometry.
  18566. */
  18567. getTotalIndices(): number;
  18568. /**
  18569. * The source mesh of the instance
  18570. */
  18571. readonly sourceMesh: Mesh;
  18572. /**
  18573. * Is this node ready to be used/rendered
  18574. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18575. * @return {boolean} is it ready
  18576. */
  18577. isReady(completeCheck?: boolean): boolean;
  18578. /**
  18579. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18580. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18581. * @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.
  18582. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18583. */
  18584. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18585. /**
  18586. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18587. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18588. * The `data` are either a numeric array either a Float32Array.
  18589. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18590. * 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).
  18591. * Note that a new underlying VertexBuffer object is created each call.
  18592. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18593. *
  18594. * Possible `kind` values :
  18595. * - VertexBuffer.PositionKind
  18596. * - VertexBuffer.UVKind
  18597. * - VertexBuffer.UV2Kind
  18598. * - VertexBuffer.UV3Kind
  18599. * - VertexBuffer.UV4Kind
  18600. * - VertexBuffer.UV5Kind
  18601. * - VertexBuffer.UV6Kind
  18602. * - VertexBuffer.ColorKind
  18603. * - VertexBuffer.MatricesIndicesKind
  18604. * - VertexBuffer.MatricesIndicesExtraKind
  18605. * - VertexBuffer.MatricesWeightsKind
  18606. * - VertexBuffer.MatricesWeightsExtraKind
  18607. *
  18608. * Returns the Mesh.
  18609. */
  18610. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18611. /**
  18612. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18613. * If the mesh has no geometry, it is simply returned as it is.
  18614. * The `data` are either a numeric array either a Float32Array.
  18615. * No new underlying VertexBuffer object is created.
  18616. * 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.
  18617. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18618. *
  18619. * Possible `kind` values :
  18620. * - VertexBuffer.PositionKind
  18621. * - VertexBuffer.UVKind
  18622. * - VertexBuffer.UV2Kind
  18623. * - VertexBuffer.UV3Kind
  18624. * - VertexBuffer.UV4Kind
  18625. * - VertexBuffer.UV5Kind
  18626. * - VertexBuffer.UV6Kind
  18627. * - VertexBuffer.ColorKind
  18628. * - VertexBuffer.MatricesIndicesKind
  18629. * - VertexBuffer.MatricesIndicesExtraKind
  18630. * - VertexBuffer.MatricesWeightsKind
  18631. * - VertexBuffer.MatricesWeightsExtraKind
  18632. *
  18633. * Returns the Mesh.
  18634. */
  18635. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18636. /**
  18637. * Sets the mesh indices.
  18638. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18639. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18640. * This method creates a new index buffer each call.
  18641. * Returns the Mesh.
  18642. */
  18643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18644. /**
  18645. * Boolean : True if the mesh owns the requested kind of data.
  18646. */
  18647. isVerticesDataPresent(kind: string): boolean;
  18648. /**
  18649. * Returns an array of indices (IndicesArray).
  18650. */
  18651. getIndices(): Nullable<IndicesArray>;
  18652. readonly _positions: Nullable<Vector3[]>;
  18653. /**
  18654. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18655. * This means the mesh underlying bounding box and sphere are recomputed.
  18656. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18657. * @returns the current mesh
  18658. */
  18659. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18660. /** @hidden */
  18661. _preActivate(): InstancedMesh;
  18662. /** @hidden */
  18663. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18664. /** @hidden */
  18665. _postActivate(): void;
  18666. getWorldMatrix(): Matrix;
  18667. readonly isAnInstance: boolean;
  18668. /**
  18669. * Returns the current associated LOD AbstractMesh.
  18670. */
  18671. getLOD(camera: Camera): AbstractMesh;
  18672. /** @hidden */
  18673. _syncSubMeshes(): InstancedMesh;
  18674. /** @hidden */
  18675. _generatePointsArray(): boolean;
  18676. /**
  18677. * Creates a new InstancedMesh from the current mesh.
  18678. * - name (string) : the cloned mesh name
  18679. * - newParent (optional Node) : the optional Node to parent the clone to.
  18680. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18681. *
  18682. * Returns the clone.
  18683. */
  18684. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18685. /**
  18686. * Disposes the InstancedMesh.
  18687. * Returns nothing.
  18688. */
  18689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18690. }
  18691. }
  18692. declare module BABYLON {
  18693. /**
  18694. * Defines the options associated with the creation of a shader material.
  18695. */
  18696. export interface IShaderMaterialOptions {
  18697. /**
  18698. * Does the material work in alpha blend mode
  18699. */
  18700. needAlphaBlending: boolean;
  18701. /**
  18702. * Does the material work in alpha test mode
  18703. */
  18704. needAlphaTesting: boolean;
  18705. /**
  18706. * The list of attribute names used in the shader
  18707. */
  18708. attributes: string[];
  18709. /**
  18710. * The list of unifrom names used in the shader
  18711. */
  18712. uniforms: string[];
  18713. /**
  18714. * The list of UBO names used in the shader
  18715. */
  18716. uniformBuffers: string[];
  18717. /**
  18718. * The list of sampler names used in the shader
  18719. */
  18720. samplers: string[];
  18721. /**
  18722. * The list of defines used in the shader
  18723. */
  18724. defines: string[];
  18725. }
  18726. /**
  18727. * 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.
  18728. *
  18729. * This returned material effects how the mesh will look based on the code in the shaders.
  18730. *
  18731. * @see http://doc.babylonjs.com/how_to/shader_material
  18732. */
  18733. export class ShaderMaterial extends Material {
  18734. private _shaderPath;
  18735. private _options;
  18736. private _textures;
  18737. private _textureArrays;
  18738. private _floats;
  18739. private _ints;
  18740. private _floatsArrays;
  18741. private _colors3;
  18742. private _colors3Arrays;
  18743. private _colors4;
  18744. private _colors4Arrays;
  18745. private _vectors2;
  18746. private _vectors3;
  18747. private _vectors4;
  18748. private _matrices;
  18749. private _matrices3x3;
  18750. private _matrices2x2;
  18751. private _vectors2Arrays;
  18752. private _vectors3Arrays;
  18753. private _vectors4Arrays;
  18754. private _cachedWorldViewMatrix;
  18755. private _cachedWorldViewProjectionMatrix;
  18756. private _renderId;
  18757. /**
  18758. * Instantiate a new shader material.
  18759. * 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.
  18760. * This returned material effects how the mesh will look based on the code in the shaders.
  18761. * @see http://doc.babylonjs.com/how_to/shader_material
  18762. * @param name Define the name of the material in the scene
  18763. * @param scene Define the scene the material belongs to
  18764. * @param shaderPath Defines the route to the shader code in one of three ways:
  18765. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18766. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18767. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18768. * @param options Define the options used to create the shader
  18769. */
  18770. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18771. /**
  18772. * Gets the options used to compile the shader.
  18773. * They can be modified to trigger a new compilation
  18774. */
  18775. readonly options: IShaderMaterialOptions;
  18776. /**
  18777. * Gets the current class name of the material e.g. "ShaderMaterial"
  18778. * Mainly use in serialization.
  18779. * @returns the class name
  18780. */
  18781. getClassName(): string;
  18782. /**
  18783. * Specifies if the material will require alpha blending
  18784. * @returns a boolean specifying if alpha blending is needed
  18785. */
  18786. needAlphaBlending(): boolean;
  18787. /**
  18788. * Specifies if this material should be rendered in alpha test mode
  18789. * @returns a boolean specifying if an alpha test is needed.
  18790. */
  18791. needAlphaTesting(): boolean;
  18792. private _checkUniform;
  18793. /**
  18794. * Set a texture in the shader.
  18795. * @param name Define the name of the uniform samplers as defined in the shader
  18796. * @param texture Define the texture to bind to this sampler
  18797. * @return the material itself allowing "fluent" like uniform updates
  18798. */
  18799. setTexture(name: string, texture: Texture): ShaderMaterial;
  18800. /**
  18801. * Set a texture array in the shader.
  18802. * @param name Define the name of the uniform sampler array as defined in the shader
  18803. * @param textures Define the list of textures to bind to this sampler
  18804. * @return the material itself allowing "fluent" like uniform updates
  18805. */
  18806. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18807. /**
  18808. * Set a float in the shader.
  18809. * @param name Define the name of the uniform as defined in the shader
  18810. * @param value Define the value to give to the uniform
  18811. * @return the material itself allowing "fluent" like uniform updates
  18812. */
  18813. setFloat(name: string, value: number): ShaderMaterial;
  18814. /**
  18815. * Set a int in the shader.
  18816. * @param name Define the name of the uniform as defined in the shader
  18817. * @param value Define the value to give to the uniform
  18818. * @return the material itself allowing "fluent" like uniform updates
  18819. */
  18820. setInt(name: string, value: number): ShaderMaterial;
  18821. /**
  18822. * Set an array of floats in the shader.
  18823. * @param name Define the name of the uniform as defined in the shader
  18824. * @param value Define the value to give to the uniform
  18825. * @return the material itself allowing "fluent" like uniform updates
  18826. */
  18827. setFloats(name: string, value: number[]): ShaderMaterial;
  18828. /**
  18829. * Set a vec3 in the shader from a Color3.
  18830. * @param name Define the name of the uniform as defined in the shader
  18831. * @param value Define the value to give to the uniform
  18832. * @return the material itself allowing "fluent" like uniform updates
  18833. */
  18834. setColor3(name: string, value: Color3): ShaderMaterial;
  18835. /**
  18836. * Set a vec3 array in the shader from a Color3 array.
  18837. * @param name Define the name of the uniform as defined in the shader
  18838. * @param value Define the value to give to the uniform
  18839. * @return the material itself allowing "fluent" like uniform updates
  18840. */
  18841. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18842. /**
  18843. * Set a vec4 in the shader from a Color4.
  18844. * @param name Define the name of the uniform as defined in the shader
  18845. * @param value Define the value to give to the uniform
  18846. * @return the material itself allowing "fluent" like uniform updates
  18847. */
  18848. setColor4(name: string, value: Color4): ShaderMaterial;
  18849. /**
  18850. * Set a vec4 array in the shader from a Color4 array.
  18851. * @param name Define the name of the uniform as defined in the shader
  18852. * @param value Define the value to give to the uniform
  18853. * @return the material itself allowing "fluent" like uniform updates
  18854. */
  18855. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18856. /**
  18857. * Set a vec2 in the shader from a Vector2.
  18858. * @param name Define the name of the uniform as defined in the shader
  18859. * @param value Define the value to give to the uniform
  18860. * @return the material itself allowing "fluent" like uniform updates
  18861. */
  18862. setVector2(name: string, value: Vector2): ShaderMaterial;
  18863. /**
  18864. * Set a vec3 in the shader from a Vector3.
  18865. * @param name Define the name of the uniform as defined in the shader
  18866. * @param value Define the value to give to the uniform
  18867. * @return the material itself allowing "fluent" like uniform updates
  18868. */
  18869. setVector3(name: string, value: Vector3): ShaderMaterial;
  18870. /**
  18871. * Set a vec4 in the shader from a Vector4.
  18872. * @param name Define the name of the uniform as defined in the shader
  18873. * @param value Define the value to give to the uniform
  18874. * @return the material itself allowing "fluent" like uniform updates
  18875. */
  18876. setVector4(name: string, value: Vector4): ShaderMaterial;
  18877. /**
  18878. * Set a mat4 in the shader from a Matrix.
  18879. * @param name Define the name of the uniform as defined in the shader
  18880. * @param value Define the value to give to the uniform
  18881. * @return the material itself allowing "fluent" like uniform updates
  18882. */
  18883. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18884. /**
  18885. * Set a mat3 in the shader from a Float32Array.
  18886. * @param name Define the name of the uniform as defined in the shader
  18887. * @param value Define the value to give to the uniform
  18888. * @return the material itself allowing "fluent" like uniform updates
  18889. */
  18890. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18891. /**
  18892. * Set a mat2 in the shader from a Float32Array.
  18893. * @param name Define the name of the uniform as defined in the shader
  18894. * @param value Define the value to give to the uniform
  18895. * @return the material itself allowing "fluent" like uniform updates
  18896. */
  18897. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18898. /**
  18899. * Set a vec2 array in the shader from a number array.
  18900. * @param name Define the name of the uniform as defined in the shader
  18901. * @param value Define the value to give to the uniform
  18902. * @return the material itself allowing "fluent" like uniform updates
  18903. */
  18904. setArray2(name: string, value: number[]): ShaderMaterial;
  18905. /**
  18906. * Set a vec3 array in the shader from a number array.
  18907. * @param name Define the name of the uniform as defined in the shader
  18908. * @param value Define the value to give to the uniform
  18909. * @return the material itself allowing "fluent" like uniform updates
  18910. */
  18911. setArray3(name: string, value: number[]): ShaderMaterial;
  18912. /**
  18913. * Set a vec4 array in the shader from a number array.
  18914. * @param name Define the name of the uniform as defined in the shader
  18915. * @param value Define the value to give to the uniform
  18916. * @return the material itself allowing "fluent" like uniform updates
  18917. */
  18918. setArray4(name: string, value: number[]): ShaderMaterial;
  18919. private _checkCache;
  18920. /**
  18921. * Specifies that the submesh is ready to be used
  18922. * @param mesh defines the mesh to check
  18923. * @param subMesh defines which submesh to check
  18924. * @param useInstances specifies that instances should be used
  18925. * @returns a boolean indicating that the submesh is ready or not
  18926. */
  18927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18928. /**
  18929. * Checks if the material is ready to render the requested mesh
  18930. * @param mesh Define the mesh to render
  18931. * @param useInstances Define whether or not the material is used with instances
  18932. * @returns true if ready, otherwise false
  18933. */
  18934. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18935. /**
  18936. * Binds the world matrix to the material
  18937. * @param world defines the world transformation matrix
  18938. */
  18939. bindOnlyWorldMatrix(world: Matrix): void;
  18940. /**
  18941. * Binds the material to the mesh
  18942. * @param world defines the world transformation matrix
  18943. * @param mesh defines the mesh to bind the material to
  18944. */
  18945. bind(world: Matrix, mesh?: Mesh): void;
  18946. /**
  18947. * Gets the active textures from the material
  18948. * @returns an array of textures
  18949. */
  18950. getActiveTextures(): BaseTexture[];
  18951. /**
  18952. * Specifies if the material uses a texture
  18953. * @param texture defines the texture to check against the material
  18954. * @returns a boolean specifying if the material uses the texture
  18955. */
  18956. hasTexture(texture: BaseTexture): boolean;
  18957. /**
  18958. * Makes a duplicate of the material, and gives it a new name
  18959. * @param name defines the new name for the duplicated material
  18960. * @returns the cloned material
  18961. */
  18962. clone(name: string): ShaderMaterial;
  18963. /**
  18964. * Disposes the material
  18965. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18966. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18967. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18968. */
  18969. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18970. /**
  18971. * Serializes this material in a JSON representation
  18972. * @returns the serialized material object
  18973. */
  18974. serialize(): any;
  18975. /**
  18976. * Creates a shader material from parsed shader material data
  18977. * @param source defines the JSON represnetation of the material
  18978. * @param scene defines the hosting scene
  18979. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18980. * @returns a new material
  18981. */
  18982. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18983. }
  18984. }
  18985. declare module BABYLON {
  18986. /** @hidden */
  18987. export var colorPixelShader: {
  18988. name: string;
  18989. shader: string;
  18990. };
  18991. }
  18992. declare module BABYLON {
  18993. /** @hidden */
  18994. export var colorVertexShader: {
  18995. name: string;
  18996. shader: string;
  18997. };
  18998. }
  18999. declare module BABYLON {
  19000. /**
  19001. * Line mesh
  19002. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19003. */
  19004. export class LinesMesh extends Mesh {
  19005. /**
  19006. * If vertex color should be applied to the mesh
  19007. */
  19008. readonly useVertexColor?: boolean | undefined;
  19009. /**
  19010. * If vertex alpha should be applied to the mesh
  19011. */
  19012. readonly useVertexAlpha?: boolean | undefined;
  19013. /**
  19014. * Color of the line (Default: White)
  19015. */
  19016. color: Color3;
  19017. /**
  19018. * Alpha of the line (Default: 1)
  19019. */
  19020. alpha: number;
  19021. /**
  19022. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19023. * This margin is expressed in world space coordinates, so its value may vary.
  19024. * Default value is 0.1
  19025. */
  19026. intersectionThreshold: number;
  19027. private _colorShader;
  19028. private color4;
  19029. /**
  19030. * Creates a new LinesMesh
  19031. * @param name defines the name
  19032. * @param scene defines the hosting scene
  19033. * @param parent defines the parent mesh if any
  19034. * @param source defines the optional source LinesMesh used to clone data from
  19035. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19036. * When false, achieved by calling a clone(), also passing False.
  19037. * This will make creation of children, recursive.
  19038. * @param useVertexColor defines if this LinesMesh supports vertex color
  19039. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19040. */
  19041. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19042. /**
  19043. * If vertex color should be applied to the mesh
  19044. */
  19045. useVertexColor?: boolean | undefined,
  19046. /**
  19047. * If vertex alpha should be applied to the mesh
  19048. */
  19049. useVertexAlpha?: boolean | undefined);
  19050. private _addClipPlaneDefine;
  19051. private _removeClipPlaneDefine;
  19052. isReady(): boolean;
  19053. /**
  19054. * Returns the string "LineMesh"
  19055. */
  19056. getClassName(): string;
  19057. /**
  19058. * @hidden
  19059. */
  19060. /**
  19061. * @hidden
  19062. */
  19063. material: Material;
  19064. /**
  19065. * @hidden
  19066. */
  19067. readonly checkCollisions: boolean;
  19068. /** @hidden */
  19069. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19070. /** @hidden */
  19071. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19072. /**
  19073. * Disposes of the line mesh
  19074. * @param doNotRecurse If children should be disposed
  19075. */
  19076. dispose(doNotRecurse?: boolean): void;
  19077. /**
  19078. * Returns a new LineMesh object cloned from the current one.
  19079. */
  19080. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19081. /**
  19082. * Creates a new InstancedLinesMesh object from the mesh model.
  19083. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19084. * @param name defines the name of the new instance
  19085. * @returns a new InstancedLinesMesh
  19086. */
  19087. createInstance(name: string): InstancedLinesMesh;
  19088. }
  19089. /**
  19090. * Creates an instance based on a source LinesMesh
  19091. */
  19092. export class InstancedLinesMesh extends InstancedMesh {
  19093. /**
  19094. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19095. * This margin is expressed in world space coordinates, so its value may vary.
  19096. * Initilized with the intersectionThreshold value of the source LinesMesh
  19097. */
  19098. intersectionThreshold: number;
  19099. constructor(name: string, source: LinesMesh);
  19100. /**
  19101. * Returns the string "InstancedLinesMesh".
  19102. */
  19103. getClassName(): string;
  19104. }
  19105. }
  19106. declare module BABYLON {
  19107. /** @hidden */
  19108. export var linePixelShader: {
  19109. name: string;
  19110. shader: string;
  19111. };
  19112. }
  19113. declare module BABYLON {
  19114. /** @hidden */
  19115. export var lineVertexShader: {
  19116. name: string;
  19117. shader: string;
  19118. };
  19119. }
  19120. declare module BABYLON {
  19121. interface AbstractMesh {
  19122. /**
  19123. * Gets the edgesRenderer associated with the mesh
  19124. */
  19125. edgesRenderer: Nullable<EdgesRenderer>;
  19126. }
  19127. interface LinesMesh {
  19128. /**
  19129. * Enables the edge rendering mode on the mesh.
  19130. * This mode makes the mesh edges visible
  19131. * @param epsilon defines the maximal distance between two angles to detect a face
  19132. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19133. * @returns the currentAbstractMesh
  19134. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19135. */
  19136. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19137. }
  19138. interface InstancedLinesMesh {
  19139. /**
  19140. * Enables the edge rendering mode on the mesh.
  19141. * This mode makes the mesh edges visible
  19142. * @param epsilon defines the maximal distance between two angles to detect a face
  19143. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19144. * @returns the current InstancedLinesMesh
  19145. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19146. */
  19147. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19148. }
  19149. /**
  19150. * Defines the minimum contract an Edges renderer should follow.
  19151. */
  19152. export interface IEdgesRenderer extends IDisposable {
  19153. /**
  19154. * Gets or sets a boolean indicating if the edgesRenderer is active
  19155. */
  19156. isEnabled: boolean;
  19157. /**
  19158. * Renders the edges of the attached mesh,
  19159. */
  19160. render(): void;
  19161. /**
  19162. * Checks wether or not the edges renderer is ready to render.
  19163. * @return true if ready, otherwise false.
  19164. */
  19165. isReady(): boolean;
  19166. }
  19167. /**
  19168. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19169. */
  19170. export class EdgesRenderer implements IEdgesRenderer {
  19171. /**
  19172. * Define the size of the edges with an orthographic camera
  19173. */
  19174. edgesWidthScalerForOrthographic: number;
  19175. /**
  19176. * Define the size of the edges with a perspective camera
  19177. */
  19178. edgesWidthScalerForPerspective: number;
  19179. protected _source: AbstractMesh;
  19180. protected _linesPositions: number[];
  19181. protected _linesNormals: number[];
  19182. protected _linesIndices: number[];
  19183. protected _epsilon: number;
  19184. protected _indicesCount: number;
  19185. protected _lineShader: ShaderMaterial;
  19186. protected _ib: DataBuffer;
  19187. protected _buffers: {
  19188. [key: string]: Nullable<VertexBuffer>;
  19189. };
  19190. protected _checkVerticesInsteadOfIndices: boolean;
  19191. private _meshRebuildObserver;
  19192. private _meshDisposeObserver;
  19193. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19194. isEnabled: boolean;
  19195. /**
  19196. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19197. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19198. * @param source Mesh used to create edges
  19199. * @param epsilon sum of angles in adjacency to check for edge
  19200. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19201. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19202. */
  19203. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19204. protected _prepareRessources(): void;
  19205. /** @hidden */
  19206. _rebuild(): void;
  19207. /**
  19208. * Releases the required resources for the edges renderer
  19209. */
  19210. dispose(): void;
  19211. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19212. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19213. /**
  19214. * Checks if the pair of p0 and p1 is en edge
  19215. * @param faceIndex
  19216. * @param edge
  19217. * @param faceNormals
  19218. * @param p0
  19219. * @param p1
  19220. * @private
  19221. */
  19222. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19223. /**
  19224. * push line into the position, normal and index buffer
  19225. * @protected
  19226. */
  19227. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19228. /**
  19229. * Generates lines edges from adjacencjes
  19230. * @private
  19231. */
  19232. _generateEdgesLines(): void;
  19233. /**
  19234. * Checks wether or not the edges renderer is ready to render.
  19235. * @return true if ready, otherwise false.
  19236. */
  19237. isReady(): boolean;
  19238. /**
  19239. * Renders the edges of the attached mesh,
  19240. */
  19241. render(): void;
  19242. }
  19243. /**
  19244. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19245. */
  19246. export class LineEdgesRenderer extends EdgesRenderer {
  19247. /**
  19248. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19249. * @param source LineMesh used to generate edges
  19250. * @param epsilon not important (specified angle for edge detection)
  19251. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19252. */
  19253. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19254. /**
  19255. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19256. */
  19257. _generateEdgesLines(): void;
  19258. }
  19259. }
  19260. declare module BABYLON {
  19261. /**
  19262. * This represents the object necessary to create a rendering group.
  19263. * This is exclusively used and created by the rendering manager.
  19264. * To modify the behavior, you use the available helpers in your scene or meshes.
  19265. * @hidden
  19266. */
  19267. export class RenderingGroup {
  19268. index: number;
  19269. private static _zeroVector;
  19270. private _scene;
  19271. private _opaqueSubMeshes;
  19272. private _transparentSubMeshes;
  19273. private _alphaTestSubMeshes;
  19274. private _depthOnlySubMeshes;
  19275. private _particleSystems;
  19276. private _spriteManagers;
  19277. private _opaqueSortCompareFn;
  19278. private _alphaTestSortCompareFn;
  19279. private _transparentSortCompareFn;
  19280. private _renderOpaque;
  19281. private _renderAlphaTest;
  19282. private _renderTransparent;
  19283. /** @hidden */
  19284. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19285. onBeforeTransparentRendering: () => void;
  19286. /**
  19287. * Set the opaque sort comparison function.
  19288. * If null the sub meshes will be render in the order they were created
  19289. */
  19290. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19291. /**
  19292. * Set the alpha test sort comparison function.
  19293. * If null the sub meshes will be render in the order they were created
  19294. */
  19295. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19296. /**
  19297. * Set the transparent sort comparison function.
  19298. * If null the sub meshes will be render in the order they were created
  19299. */
  19300. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19301. /**
  19302. * Creates a new rendering group.
  19303. * @param index The rendering group index
  19304. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19305. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19306. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19307. */
  19308. 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>);
  19309. /**
  19310. * Render all the sub meshes contained in the group.
  19311. * @param customRenderFunction Used to override the default render behaviour of the group.
  19312. * @returns true if rendered some submeshes.
  19313. */
  19314. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19315. /**
  19316. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19317. * @param subMeshes The submeshes to render
  19318. */
  19319. private renderOpaqueSorted;
  19320. /**
  19321. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19322. * @param subMeshes The submeshes to render
  19323. */
  19324. private renderAlphaTestSorted;
  19325. /**
  19326. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19327. * @param subMeshes The submeshes to render
  19328. */
  19329. private renderTransparentSorted;
  19330. /**
  19331. * Renders the submeshes in a specified order.
  19332. * @param subMeshes The submeshes to sort before render
  19333. * @param sortCompareFn The comparison function use to sort
  19334. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19335. * @param transparent Specifies to activate blending if true
  19336. */
  19337. private static renderSorted;
  19338. /**
  19339. * Renders the submeshes in the order they were dispatched (no sort applied).
  19340. * @param subMeshes The submeshes to render
  19341. */
  19342. private static renderUnsorted;
  19343. /**
  19344. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19345. * are rendered back to front if in the same alpha index.
  19346. *
  19347. * @param a The first submesh
  19348. * @param b The second submesh
  19349. * @returns The result of the comparison
  19350. */
  19351. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19352. /**
  19353. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19354. * are rendered back to front.
  19355. *
  19356. * @param a The first submesh
  19357. * @param b The second submesh
  19358. * @returns The result of the comparison
  19359. */
  19360. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19361. /**
  19362. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19363. * are rendered front to back (prevent overdraw).
  19364. *
  19365. * @param a The first submesh
  19366. * @param b The second submesh
  19367. * @returns The result of the comparison
  19368. */
  19369. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19370. /**
  19371. * Resets the different lists of submeshes to prepare a new frame.
  19372. */
  19373. prepare(): void;
  19374. dispose(): void;
  19375. /**
  19376. * Inserts the submesh in its correct queue depending on its material.
  19377. * @param subMesh The submesh to dispatch
  19378. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19379. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19380. */
  19381. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19382. dispatchSprites(spriteManager: ISpriteManager): void;
  19383. dispatchParticles(particleSystem: IParticleSystem): void;
  19384. private _renderParticles;
  19385. private _renderSprites;
  19386. }
  19387. }
  19388. declare module BABYLON {
  19389. /**
  19390. * Interface describing the different options available in the rendering manager
  19391. * regarding Auto Clear between groups.
  19392. */
  19393. export interface IRenderingManagerAutoClearSetup {
  19394. /**
  19395. * Defines whether or not autoclear is enable.
  19396. */
  19397. autoClear: boolean;
  19398. /**
  19399. * Defines whether or not to autoclear the depth buffer.
  19400. */
  19401. depth: boolean;
  19402. /**
  19403. * Defines whether or not to autoclear the stencil buffer.
  19404. */
  19405. stencil: boolean;
  19406. }
  19407. /**
  19408. * This class is used by the onRenderingGroupObservable
  19409. */
  19410. export class RenderingGroupInfo {
  19411. /**
  19412. * The Scene that being rendered
  19413. */
  19414. scene: Scene;
  19415. /**
  19416. * The camera currently used for the rendering pass
  19417. */
  19418. camera: Nullable<Camera>;
  19419. /**
  19420. * The ID of the renderingGroup being processed
  19421. */
  19422. renderingGroupId: number;
  19423. }
  19424. /**
  19425. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19426. * It is enable to manage the different groups as well as the different necessary sort functions.
  19427. * This should not be used directly aside of the few static configurations
  19428. */
  19429. export class RenderingManager {
  19430. /**
  19431. * The max id used for rendering groups (not included)
  19432. */
  19433. static MAX_RENDERINGGROUPS: number;
  19434. /**
  19435. * The min id used for rendering groups (included)
  19436. */
  19437. static MIN_RENDERINGGROUPS: number;
  19438. /**
  19439. * Used to globally prevent autoclearing scenes.
  19440. */
  19441. static AUTOCLEAR: boolean;
  19442. /**
  19443. * @hidden
  19444. */
  19445. _useSceneAutoClearSetup: boolean;
  19446. private _scene;
  19447. private _renderingGroups;
  19448. private _depthStencilBufferAlreadyCleaned;
  19449. private _autoClearDepthStencil;
  19450. private _customOpaqueSortCompareFn;
  19451. private _customAlphaTestSortCompareFn;
  19452. private _customTransparentSortCompareFn;
  19453. private _renderingGroupInfo;
  19454. /**
  19455. * Instantiates a new rendering group for a particular scene
  19456. * @param scene Defines the scene the groups belongs to
  19457. */
  19458. constructor(scene: Scene);
  19459. private _clearDepthStencilBuffer;
  19460. /**
  19461. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19462. * @hidden
  19463. */
  19464. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19465. /**
  19466. * Resets the different information of the group to prepare a new frame
  19467. * @hidden
  19468. */
  19469. reset(): void;
  19470. /**
  19471. * Dispose and release the group and its associated resources.
  19472. * @hidden
  19473. */
  19474. dispose(): void;
  19475. /**
  19476. * Clear the info related to rendering groups preventing retention points during dispose.
  19477. */
  19478. freeRenderingGroups(): void;
  19479. private _prepareRenderingGroup;
  19480. /**
  19481. * Add a sprite manager to the rendering manager in order to render it this frame.
  19482. * @param spriteManager Define the sprite manager to render
  19483. */
  19484. dispatchSprites(spriteManager: ISpriteManager): void;
  19485. /**
  19486. * Add a particle system to the rendering manager in order to render it this frame.
  19487. * @param particleSystem Define the particle system to render
  19488. */
  19489. dispatchParticles(particleSystem: IParticleSystem): void;
  19490. /**
  19491. * Add a submesh to the manager in order to render it this frame
  19492. * @param subMesh The submesh to dispatch
  19493. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19494. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19495. */
  19496. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19497. /**
  19498. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19499. * This allowed control for front to back rendering or reversly depending of the special needs.
  19500. *
  19501. * @param renderingGroupId The rendering group id corresponding to its index
  19502. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19503. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19504. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19505. */
  19506. 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;
  19507. /**
  19508. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19509. *
  19510. * @param renderingGroupId The rendering group id corresponding to its index
  19511. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19512. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19513. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19514. */
  19515. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19516. /**
  19517. * Gets the current auto clear configuration for one rendering group of the rendering
  19518. * manager.
  19519. * @param index the rendering group index to get the information for
  19520. * @returns The auto clear setup for the requested rendering group
  19521. */
  19522. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19523. }
  19524. }
  19525. declare module BABYLON {
  19526. /**
  19527. * This Helps creating a texture that will be created from a camera in your scene.
  19528. * It is basically a dynamic texture that could be used to create special effects for instance.
  19529. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19530. */
  19531. export class RenderTargetTexture extends Texture {
  19532. isCube: boolean;
  19533. /**
  19534. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19535. */
  19536. static readonly REFRESHRATE_RENDER_ONCE: number;
  19537. /**
  19538. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19539. */
  19540. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19541. /**
  19542. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19543. * the central point of your effect and can save a lot of performances.
  19544. */
  19545. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19546. /**
  19547. * Use this predicate to dynamically define the list of mesh you want to render.
  19548. * If set, the renderList property will be overwritten.
  19549. */
  19550. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19551. private _renderList;
  19552. /**
  19553. * Use this list to define the list of mesh you want to render.
  19554. */
  19555. renderList: Nullable<Array<AbstractMesh>>;
  19556. private _hookArray;
  19557. /**
  19558. * Define if particles should be rendered in your texture.
  19559. */
  19560. renderParticles: boolean;
  19561. /**
  19562. * Define if sprites should be rendered in your texture.
  19563. */
  19564. renderSprites: boolean;
  19565. /**
  19566. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19567. */
  19568. coordinatesMode: number;
  19569. /**
  19570. * Define the camera used to render the texture.
  19571. */
  19572. activeCamera: Nullable<Camera>;
  19573. /**
  19574. * Override the render function of the texture with your own one.
  19575. */
  19576. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19577. /**
  19578. * Define if camera post processes should be use while rendering the texture.
  19579. */
  19580. useCameraPostProcesses: boolean;
  19581. /**
  19582. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19583. */
  19584. ignoreCameraViewport: boolean;
  19585. private _postProcessManager;
  19586. private _postProcesses;
  19587. private _resizeObserver;
  19588. /**
  19589. * An event triggered when the texture is unbind.
  19590. */
  19591. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19592. /**
  19593. * An event triggered when the texture is unbind.
  19594. */
  19595. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19596. private _onAfterUnbindObserver;
  19597. /**
  19598. * Set a after unbind callback in the texture.
  19599. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19600. */
  19601. onAfterUnbind: () => void;
  19602. /**
  19603. * An event triggered before rendering the texture
  19604. */
  19605. onBeforeRenderObservable: Observable<number>;
  19606. private _onBeforeRenderObserver;
  19607. /**
  19608. * Set a before render callback in the texture.
  19609. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19610. */
  19611. onBeforeRender: (faceIndex: number) => void;
  19612. /**
  19613. * An event triggered after rendering the texture
  19614. */
  19615. onAfterRenderObservable: Observable<number>;
  19616. private _onAfterRenderObserver;
  19617. /**
  19618. * Set a after render callback in the texture.
  19619. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19620. */
  19621. onAfterRender: (faceIndex: number) => void;
  19622. /**
  19623. * An event triggered after the texture clear
  19624. */
  19625. onClearObservable: Observable<Engine>;
  19626. private _onClearObserver;
  19627. /**
  19628. * Set a clear callback in the texture.
  19629. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19630. */
  19631. onClear: (Engine: Engine) => void;
  19632. /**
  19633. * An event triggered when the texture is resized.
  19634. */
  19635. onResizeObservable: Observable<RenderTargetTexture>;
  19636. /**
  19637. * Define the clear color of the Render Target if it should be different from the scene.
  19638. */
  19639. clearColor: Color4;
  19640. protected _size: number | {
  19641. width: number;
  19642. height: number;
  19643. };
  19644. protected _initialSizeParameter: number | {
  19645. width: number;
  19646. height: number;
  19647. } | {
  19648. ratio: number;
  19649. };
  19650. protected _sizeRatio: Nullable<number>;
  19651. /** @hidden */
  19652. _generateMipMaps: boolean;
  19653. protected _renderingManager: RenderingManager;
  19654. /** @hidden */
  19655. _waitingRenderList: string[];
  19656. protected _doNotChangeAspectRatio: boolean;
  19657. protected _currentRefreshId: number;
  19658. protected _refreshRate: number;
  19659. protected _textureMatrix: Matrix;
  19660. protected _samples: number;
  19661. protected _renderTargetOptions: RenderTargetCreationOptions;
  19662. /**
  19663. * Gets render target creation options that were used.
  19664. */
  19665. readonly renderTargetOptions: RenderTargetCreationOptions;
  19666. protected _engine: Engine;
  19667. protected _onRatioRescale(): void;
  19668. /**
  19669. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19670. * It must define where the camera used to render the texture is set
  19671. */
  19672. boundingBoxPosition: Vector3;
  19673. private _boundingBoxSize;
  19674. /**
  19675. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19676. * When defined, the cubemap will switch to local mode
  19677. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19678. * @example https://www.babylonjs-playground.com/#RNASML
  19679. */
  19680. boundingBoxSize: Vector3;
  19681. /**
  19682. * In case the RTT has been created with a depth texture, get the associated
  19683. * depth texture.
  19684. * Otherwise, return null.
  19685. */
  19686. depthStencilTexture: Nullable<InternalTexture>;
  19687. /**
  19688. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19689. * or used a shadow, depth texture...
  19690. * @param name The friendly name of the texture
  19691. * @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)
  19692. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19693. * @param generateMipMaps True if mip maps need to be generated after render.
  19694. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19695. * @param type The type of the buffer in the RTT (int, half float, float...)
  19696. * @param isCube True if a cube texture needs to be created
  19697. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19698. * @param generateDepthBuffer True to generate a depth buffer
  19699. * @param generateStencilBuffer True to generate a stencil buffer
  19700. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19701. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19702. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19703. */
  19704. constructor(name: string, size: number | {
  19705. width: number;
  19706. height: number;
  19707. } | {
  19708. ratio: number;
  19709. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19710. /**
  19711. * Creates a depth stencil texture.
  19712. * This is only available in WebGL 2 or with the depth texture extension available.
  19713. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19714. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19715. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19716. */
  19717. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19718. private _processSizeParameter;
  19719. /**
  19720. * Define the number of samples to use in case of MSAA.
  19721. * It defaults to one meaning no MSAA has been enabled.
  19722. */
  19723. samples: number;
  19724. /**
  19725. * Resets the refresh counter of the texture and start bak from scratch.
  19726. * Could be useful to regenerate the texture if it is setup to render only once.
  19727. */
  19728. resetRefreshCounter(): void;
  19729. /**
  19730. * Define the refresh rate of the texture or the rendering frequency.
  19731. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19732. */
  19733. refreshRate: number;
  19734. /**
  19735. * Adds a post process to the render target rendering passes.
  19736. * @param postProcess define the post process to add
  19737. */
  19738. addPostProcess(postProcess: PostProcess): void;
  19739. /**
  19740. * Clear all the post processes attached to the render target
  19741. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19742. */
  19743. clearPostProcesses(dispose?: boolean): void;
  19744. /**
  19745. * Remove one of the post process from the list of attached post processes to the texture
  19746. * @param postProcess define the post process to remove from the list
  19747. */
  19748. removePostProcess(postProcess: PostProcess): void;
  19749. /** @hidden */
  19750. _shouldRender(): boolean;
  19751. /**
  19752. * Gets the actual render size of the texture.
  19753. * @returns the width of the render size
  19754. */
  19755. getRenderSize(): number;
  19756. /**
  19757. * Gets the actual render width of the texture.
  19758. * @returns the width of the render size
  19759. */
  19760. getRenderWidth(): number;
  19761. /**
  19762. * Gets the actual render height of the texture.
  19763. * @returns the height of the render size
  19764. */
  19765. getRenderHeight(): number;
  19766. /**
  19767. * Get if the texture can be rescaled or not.
  19768. */
  19769. readonly canRescale: boolean;
  19770. /**
  19771. * Resize the texture using a ratio.
  19772. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19773. */
  19774. scale(ratio: number): void;
  19775. /**
  19776. * Get the texture reflection matrix used to rotate/transform the reflection.
  19777. * @returns the reflection matrix
  19778. */
  19779. getReflectionTextureMatrix(): Matrix;
  19780. /**
  19781. * Resize the texture to a new desired size.
  19782. * Be carrefull as it will recreate all the data in the new texture.
  19783. * @param size Define the new size. It can be:
  19784. * - a number for squared texture,
  19785. * - an object containing { width: number, height: number }
  19786. * - or an object containing a ratio { ratio: number }
  19787. */
  19788. resize(size: number | {
  19789. width: number;
  19790. height: number;
  19791. } | {
  19792. ratio: number;
  19793. }): void;
  19794. /**
  19795. * Renders all the objects from the render list into the texture.
  19796. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19797. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19798. */
  19799. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19800. private _bestReflectionRenderTargetDimension;
  19801. /**
  19802. * @hidden
  19803. * @param faceIndex face index to bind to if this is a cubetexture
  19804. */
  19805. _bindFrameBuffer(faceIndex?: number): void;
  19806. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19807. private renderToTarget;
  19808. /**
  19809. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19810. * This allowed control for front to back rendering or reversly depending of the special needs.
  19811. *
  19812. * @param renderingGroupId The rendering group id corresponding to its index
  19813. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19814. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19815. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19816. */
  19817. 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;
  19818. /**
  19819. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19820. *
  19821. * @param renderingGroupId The rendering group id corresponding to its index
  19822. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19823. */
  19824. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19825. /**
  19826. * Clones the texture.
  19827. * @returns the cloned texture
  19828. */
  19829. clone(): RenderTargetTexture;
  19830. /**
  19831. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19832. * @returns The JSON representation of the texture
  19833. */
  19834. serialize(): any;
  19835. /**
  19836. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19837. */
  19838. disposeFramebufferObjects(): void;
  19839. /**
  19840. * Dispose the texture and release its associated resources.
  19841. */
  19842. dispose(): void;
  19843. /** @hidden */
  19844. _rebuild(): void;
  19845. /**
  19846. * Clear the info related to rendering groups preventing retention point in material dispose.
  19847. */
  19848. freeRenderingGroups(): void;
  19849. /**
  19850. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19851. * @returns the view count
  19852. */
  19853. getViewCount(): number;
  19854. }
  19855. }
  19856. declare module BABYLON {
  19857. /**
  19858. * Base class for the main features of a material in Babylon.js
  19859. */
  19860. export class Material implements IAnimatable {
  19861. /**
  19862. * Returns the triangle fill mode
  19863. */
  19864. static readonly TriangleFillMode: number;
  19865. /**
  19866. * Returns the wireframe mode
  19867. */
  19868. static readonly WireFrameFillMode: number;
  19869. /**
  19870. * Returns the point fill mode
  19871. */
  19872. static readonly PointFillMode: number;
  19873. /**
  19874. * Returns the point list draw mode
  19875. */
  19876. static readonly PointListDrawMode: number;
  19877. /**
  19878. * Returns the line list draw mode
  19879. */
  19880. static readonly LineListDrawMode: number;
  19881. /**
  19882. * Returns the line loop draw mode
  19883. */
  19884. static readonly LineLoopDrawMode: number;
  19885. /**
  19886. * Returns the line strip draw mode
  19887. */
  19888. static readonly LineStripDrawMode: number;
  19889. /**
  19890. * Returns the triangle strip draw mode
  19891. */
  19892. static readonly TriangleStripDrawMode: number;
  19893. /**
  19894. * Returns the triangle fan draw mode
  19895. */
  19896. static readonly TriangleFanDrawMode: number;
  19897. /**
  19898. * Stores the clock-wise side orientation
  19899. */
  19900. static readonly ClockWiseSideOrientation: number;
  19901. /**
  19902. * Stores the counter clock-wise side orientation
  19903. */
  19904. static readonly CounterClockWiseSideOrientation: number;
  19905. /**
  19906. * The dirty texture flag value
  19907. */
  19908. static readonly TextureDirtyFlag: number;
  19909. /**
  19910. * The dirty light flag value
  19911. */
  19912. static readonly LightDirtyFlag: number;
  19913. /**
  19914. * The dirty fresnel flag value
  19915. */
  19916. static readonly FresnelDirtyFlag: number;
  19917. /**
  19918. * The dirty attribute flag value
  19919. */
  19920. static readonly AttributesDirtyFlag: number;
  19921. /**
  19922. * The dirty misc flag value
  19923. */
  19924. static readonly MiscDirtyFlag: number;
  19925. /**
  19926. * The all dirty flag value
  19927. */
  19928. static readonly AllDirtyFlag: number;
  19929. /**
  19930. * The ID of the material
  19931. */
  19932. id: string;
  19933. /**
  19934. * Gets or sets the unique id of the material
  19935. */
  19936. uniqueId: number;
  19937. /**
  19938. * The name of the material
  19939. */
  19940. name: string;
  19941. /**
  19942. * Gets or sets user defined metadata
  19943. */
  19944. metadata: any;
  19945. /**
  19946. * For internal use only. Please do not use.
  19947. */
  19948. reservedDataStore: any;
  19949. /**
  19950. * Specifies if the ready state should be checked on each call
  19951. */
  19952. checkReadyOnEveryCall: boolean;
  19953. /**
  19954. * Specifies if the ready state should be checked once
  19955. */
  19956. checkReadyOnlyOnce: boolean;
  19957. /**
  19958. * The state of the material
  19959. */
  19960. state: string;
  19961. /**
  19962. * The alpha value of the material
  19963. */
  19964. protected _alpha: number;
  19965. /**
  19966. * List of inspectable custom properties (used by the Inspector)
  19967. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19968. */
  19969. inspectableCustomProperties: IInspectable[];
  19970. /**
  19971. * Sets the alpha value of the material
  19972. */
  19973. /**
  19974. * Gets the alpha value of the material
  19975. */
  19976. alpha: number;
  19977. /**
  19978. * Specifies if back face culling is enabled
  19979. */
  19980. protected _backFaceCulling: boolean;
  19981. /**
  19982. * Sets the back-face culling state
  19983. */
  19984. /**
  19985. * Gets the back-face culling state
  19986. */
  19987. backFaceCulling: boolean;
  19988. /**
  19989. * Stores the value for side orientation
  19990. */
  19991. sideOrientation: number;
  19992. /**
  19993. * Callback triggered when the material is compiled
  19994. */
  19995. onCompiled: Nullable<(effect: Effect) => void>;
  19996. /**
  19997. * Callback triggered when an error occurs
  19998. */
  19999. onError: Nullable<(effect: Effect, errors: string) => void>;
  20000. /**
  20001. * Callback triggered to get the render target textures
  20002. */
  20003. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20004. /**
  20005. * Gets a boolean indicating that current material needs to register RTT
  20006. */
  20007. readonly hasRenderTargetTextures: boolean;
  20008. /**
  20009. * Specifies if the material should be serialized
  20010. */
  20011. doNotSerialize: boolean;
  20012. /**
  20013. * @hidden
  20014. */
  20015. _storeEffectOnSubMeshes: boolean;
  20016. /**
  20017. * Stores the animations for the material
  20018. */
  20019. animations: Nullable<Array<Animation>>;
  20020. /**
  20021. * An event triggered when the material is disposed
  20022. */
  20023. onDisposeObservable: Observable<Material>;
  20024. /**
  20025. * An observer which watches for dispose events
  20026. */
  20027. private _onDisposeObserver;
  20028. private _onUnBindObservable;
  20029. /**
  20030. * Called during a dispose event
  20031. */
  20032. onDispose: () => void;
  20033. private _onBindObservable;
  20034. /**
  20035. * An event triggered when the material is bound
  20036. */
  20037. readonly onBindObservable: Observable<AbstractMesh>;
  20038. /**
  20039. * An observer which watches for bind events
  20040. */
  20041. private _onBindObserver;
  20042. /**
  20043. * Called during a bind event
  20044. */
  20045. onBind: (Mesh: AbstractMesh) => void;
  20046. /**
  20047. * An event triggered when the material is unbound
  20048. */
  20049. readonly onUnBindObservable: Observable<Material>;
  20050. /**
  20051. * Stores the value of the alpha mode
  20052. */
  20053. private _alphaMode;
  20054. /**
  20055. * Sets the value of the alpha mode.
  20056. *
  20057. * | Value | Type | Description |
  20058. * | --- | --- | --- |
  20059. * | 0 | ALPHA_DISABLE | |
  20060. * | 1 | ALPHA_ADD | |
  20061. * | 2 | ALPHA_COMBINE | |
  20062. * | 3 | ALPHA_SUBTRACT | |
  20063. * | 4 | ALPHA_MULTIPLY | |
  20064. * | 5 | ALPHA_MAXIMIZED | |
  20065. * | 6 | ALPHA_ONEONE | |
  20066. * | 7 | ALPHA_PREMULTIPLIED | |
  20067. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20068. * | 9 | ALPHA_INTERPOLATE | |
  20069. * | 10 | ALPHA_SCREENMODE | |
  20070. *
  20071. */
  20072. /**
  20073. * Gets the value of the alpha mode
  20074. */
  20075. alphaMode: number;
  20076. /**
  20077. * Stores the state of the need depth pre-pass value
  20078. */
  20079. private _needDepthPrePass;
  20080. /**
  20081. * Sets the need depth pre-pass value
  20082. */
  20083. /**
  20084. * Gets the depth pre-pass value
  20085. */
  20086. needDepthPrePass: boolean;
  20087. /**
  20088. * Specifies if depth writing should be disabled
  20089. */
  20090. disableDepthWrite: boolean;
  20091. /**
  20092. * Specifies if depth writing should be forced
  20093. */
  20094. forceDepthWrite: boolean;
  20095. /**
  20096. * Specifies if there should be a separate pass for culling
  20097. */
  20098. separateCullingPass: boolean;
  20099. /**
  20100. * Stores the state specifing if fog should be enabled
  20101. */
  20102. private _fogEnabled;
  20103. /**
  20104. * Sets the state for enabling fog
  20105. */
  20106. /**
  20107. * Gets the value of the fog enabled state
  20108. */
  20109. fogEnabled: boolean;
  20110. /**
  20111. * Stores the size of points
  20112. */
  20113. pointSize: number;
  20114. /**
  20115. * Stores the z offset value
  20116. */
  20117. zOffset: number;
  20118. /**
  20119. * Gets a value specifying if wireframe mode is enabled
  20120. */
  20121. /**
  20122. * Sets the state of wireframe mode
  20123. */
  20124. wireframe: boolean;
  20125. /**
  20126. * Gets the value specifying if point clouds are enabled
  20127. */
  20128. /**
  20129. * Sets the state of point cloud mode
  20130. */
  20131. pointsCloud: boolean;
  20132. /**
  20133. * Gets the material fill mode
  20134. */
  20135. /**
  20136. * Sets the material fill mode
  20137. */
  20138. fillMode: number;
  20139. /**
  20140. * @hidden
  20141. * Stores the effects for the material
  20142. */
  20143. _effect: Nullable<Effect>;
  20144. /**
  20145. * @hidden
  20146. * Specifies if the material was previously ready
  20147. */
  20148. _wasPreviouslyReady: boolean;
  20149. /**
  20150. * Specifies if uniform buffers should be used
  20151. */
  20152. private _useUBO;
  20153. /**
  20154. * Stores a reference to the scene
  20155. */
  20156. private _scene;
  20157. /**
  20158. * Stores the fill mode state
  20159. */
  20160. private _fillMode;
  20161. /**
  20162. * Specifies if the depth write state should be cached
  20163. */
  20164. private _cachedDepthWriteState;
  20165. /**
  20166. * Stores the uniform buffer
  20167. */
  20168. protected _uniformBuffer: UniformBuffer;
  20169. /** @hidden */
  20170. _indexInSceneMaterialArray: number;
  20171. /** @hidden */
  20172. meshMap: Nullable<{
  20173. [id: string]: AbstractMesh | undefined;
  20174. }>;
  20175. /**
  20176. * Creates a material instance
  20177. * @param name defines the name of the material
  20178. * @param scene defines the scene to reference
  20179. * @param doNotAdd specifies if the material should be added to the scene
  20180. */
  20181. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20182. /**
  20183. * Returns a string representation of the current material
  20184. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20185. * @returns a string with material information
  20186. */
  20187. toString(fullDetails?: boolean): string;
  20188. /**
  20189. * Gets the class name of the material
  20190. * @returns a string with the class name of the material
  20191. */
  20192. getClassName(): string;
  20193. /**
  20194. * Specifies if updates for the material been locked
  20195. */
  20196. readonly isFrozen: boolean;
  20197. /**
  20198. * Locks updates for the material
  20199. */
  20200. freeze(): void;
  20201. /**
  20202. * Unlocks updates for the material
  20203. */
  20204. unfreeze(): void;
  20205. /**
  20206. * Specifies if the material is ready to be used
  20207. * @param mesh defines the mesh to check
  20208. * @param useInstances specifies if instances should be used
  20209. * @returns a boolean indicating if the material is ready to be used
  20210. */
  20211. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20212. /**
  20213. * Specifies that the submesh is ready to be used
  20214. * @param mesh defines the mesh to check
  20215. * @param subMesh defines which submesh to check
  20216. * @param useInstances specifies that instances should be used
  20217. * @returns a boolean indicating that the submesh is ready or not
  20218. */
  20219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20220. /**
  20221. * Returns the material effect
  20222. * @returns the effect associated with the material
  20223. */
  20224. getEffect(): Nullable<Effect>;
  20225. /**
  20226. * Returns the current scene
  20227. * @returns a Scene
  20228. */
  20229. getScene(): Scene;
  20230. /**
  20231. * Specifies if the material will require alpha blending
  20232. * @returns a boolean specifying if alpha blending is needed
  20233. */
  20234. needAlphaBlending(): boolean;
  20235. /**
  20236. * Specifies if the mesh will require alpha blending
  20237. * @param mesh defines the mesh to check
  20238. * @returns a boolean specifying if alpha blending is needed for the mesh
  20239. */
  20240. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20241. /**
  20242. * Specifies if this material should be rendered in alpha test mode
  20243. * @returns a boolean specifying if an alpha test is needed.
  20244. */
  20245. needAlphaTesting(): boolean;
  20246. /**
  20247. * Gets the texture used for the alpha test
  20248. * @returns the texture to use for alpha testing
  20249. */
  20250. getAlphaTestTexture(): Nullable<BaseTexture>;
  20251. /**
  20252. * Marks the material to indicate that it needs to be re-calculated
  20253. */
  20254. markDirty(): void;
  20255. /** @hidden */
  20256. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20257. /**
  20258. * Binds the material to the mesh
  20259. * @param world defines the world transformation matrix
  20260. * @param mesh defines the mesh to bind the material to
  20261. */
  20262. bind(world: Matrix, mesh?: Mesh): void;
  20263. /**
  20264. * Binds the submesh to the material
  20265. * @param world defines the world transformation matrix
  20266. * @param mesh defines the mesh containing the submesh
  20267. * @param subMesh defines the submesh to bind the material to
  20268. */
  20269. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20270. /**
  20271. * Binds the world matrix to the material
  20272. * @param world defines the world transformation matrix
  20273. */
  20274. bindOnlyWorldMatrix(world: Matrix): void;
  20275. /**
  20276. * Binds the scene's uniform buffer to the effect.
  20277. * @param effect defines the effect to bind to the scene uniform buffer
  20278. * @param sceneUbo defines the uniform buffer storing scene data
  20279. */
  20280. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20281. /**
  20282. * Binds the view matrix to the effect
  20283. * @param effect defines the effect to bind the view matrix to
  20284. */
  20285. bindView(effect: Effect): void;
  20286. /**
  20287. * Binds the view projection matrix to the effect
  20288. * @param effect defines the effect to bind the view projection matrix to
  20289. */
  20290. bindViewProjection(effect: Effect): void;
  20291. /**
  20292. * Specifies if material alpha testing should be turned on for the mesh
  20293. * @param mesh defines the mesh to check
  20294. */
  20295. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20296. /**
  20297. * Processes to execute after binding the material to a mesh
  20298. * @param mesh defines the rendered mesh
  20299. */
  20300. protected _afterBind(mesh?: Mesh): void;
  20301. /**
  20302. * Unbinds the material from the mesh
  20303. */
  20304. unbind(): void;
  20305. /**
  20306. * Gets the active textures from the material
  20307. * @returns an array of textures
  20308. */
  20309. getActiveTextures(): BaseTexture[];
  20310. /**
  20311. * Specifies if the material uses a texture
  20312. * @param texture defines the texture to check against the material
  20313. * @returns a boolean specifying if the material uses the texture
  20314. */
  20315. hasTexture(texture: BaseTexture): boolean;
  20316. /**
  20317. * Makes a duplicate of the material, and gives it a new name
  20318. * @param name defines the new name for the duplicated material
  20319. * @returns the cloned material
  20320. */
  20321. clone(name: string): Nullable<Material>;
  20322. /**
  20323. * Gets the meshes bound to the material
  20324. * @returns an array of meshes bound to the material
  20325. */
  20326. getBindedMeshes(): AbstractMesh[];
  20327. /**
  20328. * Force shader compilation
  20329. * @param mesh defines the mesh associated with this material
  20330. * @param onCompiled defines a function to execute once the material is compiled
  20331. * @param options defines the options to configure the compilation
  20332. */
  20333. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20334. clipPlane: boolean;
  20335. }>): void;
  20336. /**
  20337. * Force shader compilation
  20338. * @param mesh defines the mesh that will use this material
  20339. * @param options defines additional options for compiling the shaders
  20340. * @returns a promise that resolves when the compilation completes
  20341. */
  20342. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20343. clipPlane: boolean;
  20344. }>): Promise<void>;
  20345. private static readonly _AllDirtyCallBack;
  20346. private static readonly _ImageProcessingDirtyCallBack;
  20347. private static readonly _TextureDirtyCallBack;
  20348. private static readonly _FresnelDirtyCallBack;
  20349. private static readonly _MiscDirtyCallBack;
  20350. private static readonly _LightsDirtyCallBack;
  20351. private static readonly _AttributeDirtyCallBack;
  20352. private static _FresnelAndMiscDirtyCallBack;
  20353. private static _TextureAndMiscDirtyCallBack;
  20354. private static readonly _DirtyCallbackArray;
  20355. private static readonly _RunDirtyCallBacks;
  20356. /**
  20357. * Marks a define in the material to indicate that it needs to be re-computed
  20358. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20359. */
  20360. markAsDirty(flag: number): void;
  20361. /**
  20362. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20363. * @param func defines a function which checks material defines against the submeshes
  20364. */
  20365. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20366. /**
  20367. * Indicates that we need to re-calculated for all submeshes
  20368. */
  20369. protected _markAllSubMeshesAsAllDirty(): void;
  20370. /**
  20371. * Indicates that image processing needs to be re-calculated for all submeshes
  20372. */
  20373. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20374. /**
  20375. * Indicates that textures need to be re-calculated for all submeshes
  20376. */
  20377. protected _markAllSubMeshesAsTexturesDirty(): void;
  20378. /**
  20379. * Indicates that fresnel needs to be re-calculated for all submeshes
  20380. */
  20381. protected _markAllSubMeshesAsFresnelDirty(): void;
  20382. /**
  20383. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20384. */
  20385. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20386. /**
  20387. * Indicates that lights need to be re-calculated for all submeshes
  20388. */
  20389. protected _markAllSubMeshesAsLightsDirty(): void;
  20390. /**
  20391. * Indicates that attributes need to be re-calculated for all submeshes
  20392. */
  20393. protected _markAllSubMeshesAsAttributesDirty(): void;
  20394. /**
  20395. * Indicates that misc needs to be re-calculated for all submeshes
  20396. */
  20397. protected _markAllSubMeshesAsMiscDirty(): void;
  20398. /**
  20399. * Indicates that textures and misc need to be re-calculated for all submeshes
  20400. */
  20401. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20402. /**
  20403. * Disposes the material
  20404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20406. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20407. */
  20408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20409. /** @hidden */
  20410. private releaseVertexArrayObject;
  20411. /**
  20412. * Serializes this material
  20413. * @returns the serialized material object
  20414. */
  20415. serialize(): any;
  20416. /**
  20417. * Creates a material from parsed material data
  20418. * @param parsedMaterial defines parsed material data
  20419. * @param scene defines the hosting scene
  20420. * @param rootUrl defines the root URL to use to load textures
  20421. * @returns a new material
  20422. */
  20423. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20424. }
  20425. }
  20426. declare module BABYLON {
  20427. /**
  20428. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20429. * separate meshes. This can be use to improve performances.
  20430. * @see http://doc.babylonjs.com/how_to/multi_materials
  20431. */
  20432. export class MultiMaterial extends Material {
  20433. private _subMaterials;
  20434. /**
  20435. * Gets or Sets the list of Materials used within the multi material.
  20436. * They need to be ordered according to the submeshes order in the associated mesh
  20437. */
  20438. subMaterials: Nullable<Material>[];
  20439. /**
  20440. * Function used to align with Node.getChildren()
  20441. * @returns the list of Materials used within the multi material
  20442. */
  20443. getChildren(): Nullable<Material>[];
  20444. /**
  20445. * Instantiates a new Multi Material
  20446. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20447. * separate meshes. This can be use to improve performances.
  20448. * @see http://doc.babylonjs.com/how_to/multi_materials
  20449. * @param name Define the name in the scene
  20450. * @param scene Define the scene the material belongs to
  20451. */
  20452. constructor(name: string, scene: Scene);
  20453. private _hookArray;
  20454. /**
  20455. * Get one of the submaterial by its index in the submaterials array
  20456. * @param index The index to look the sub material at
  20457. * @returns The Material if the index has been defined
  20458. */
  20459. getSubMaterial(index: number): Nullable<Material>;
  20460. /**
  20461. * Get the list of active textures for the whole sub materials list.
  20462. * @returns All the textures that will be used during the rendering
  20463. */
  20464. getActiveTextures(): BaseTexture[];
  20465. /**
  20466. * Gets the current class name of the material e.g. "MultiMaterial"
  20467. * Mainly use in serialization.
  20468. * @returns the class name
  20469. */
  20470. getClassName(): string;
  20471. /**
  20472. * Checks if the material is ready to render the requested sub mesh
  20473. * @param mesh Define the mesh the submesh belongs to
  20474. * @param subMesh Define the sub mesh to look readyness for
  20475. * @param useInstances Define whether or not the material is used with instances
  20476. * @returns true if ready, otherwise false
  20477. */
  20478. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20479. /**
  20480. * Clones the current material and its related sub materials
  20481. * @param name Define the name of the newly cloned material
  20482. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20483. * @returns the cloned material
  20484. */
  20485. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20486. /**
  20487. * Serializes the materials into a JSON representation.
  20488. * @returns the JSON representation
  20489. */
  20490. serialize(): any;
  20491. /**
  20492. * Dispose the material and release its associated resources
  20493. * @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)
  20494. * @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)
  20495. * @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)
  20496. */
  20497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20498. /**
  20499. * Creates a MultiMaterial from parsed MultiMaterial data.
  20500. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20501. * @param scene defines the hosting scene
  20502. * @returns a new MultiMaterial
  20503. */
  20504. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20505. }
  20506. }
  20507. declare module BABYLON {
  20508. /**
  20509. * Base class for submeshes
  20510. */
  20511. export class BaseSubMesh {
  20512. /** @hidden */
  20513. _materialDefines: Nullable<MaterialDefines>;
  20514. /** @hidden */
  20515. _materialEffect: Nullable<Effect>;
  20516. /**
  20517. * Gets associated effect
  20518. */
  20519. readonly effect: Nullable<Effect>;
  20520. /**
  20521. * Sets associated effect (effect used to render this submesh)
  20522. * @param effect defines the effect to associate with
  20523. * @param defines defines the set of defines used to compile this effect
  20524. */
  20525. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20526. }
  20527. /**
  20528. * Defines a subdivision inside a mesh
  20529. */
  20530. export class SubMesh extends BaseSubMesh implements ICullable {
  20531. /** the material index to use */
  20532. materialIndex: number;
  20533. /** vertex index start */
  20534. verticesStart: number;
  20535. /** vertices count */
  20536. verticesCount: number;
  20537. /** index start */
  20538. indexStart: number;
  20539. /** indices count */
  20540. indexCount: number;
  20541. /** @hidden */
  20542. _linesIndexCount: number;
  20543. private _mesh;
  20544. private _renderingMesh;
  20545. private _boundingInfo;
  20546. private _linesIndexBuffer;
  20547. /** @hidden */
  20548. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20549. /** @hidden */
  20550. _trianglePlanes: Plane[];
  20551. /** @hidden */
  20552. _lastColliderTransformMatrix: Nullable<Matrix>;
  20553. /** @hidden */
  20554. _renderId: number;
  20555. /** @hidden */
  20556. _alphaIndex: number;
  20557. /** @hidden */
  20558. _distanceToCamera: number;
  20559. /** @hidden */
  20560. _id: number;
  20561. private _currentMaterial;
  20562. /**
  20563. * Add a new submesh to a mesh
  20564. * @param materialIndex defines the material index to use
  20565. * @param verticesStart defines vertex index start
  20566. * @param verticesCount defines vertices count
  20567. * @param indexStart defines index start
  20568. * @param indexCount defines indices count
  20569. * @param mesh defines the parent mesh
  20570. * @param renderingMesh defines an optional rendering mesh
  20571. * @param createBoundingBox defines if bounding box should be created for this submesh
  20572. * @returns the new submesh
  20573. */
  20574. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20575. /**
  20576. * Creates a new submesh
  20577. * @param materialIndex defines the material index to use
  20578. * @param verticesStart defines vertex index start
  20579. * @param verticesCount defines vertices count
  20580. * @param indexStart defines index start
  20581. * @param indexCount defines indices count
  20582. * @param mesh defines the parent mesh
  20583. * @param renderingMesh defines an optional rendering mesh
  20584. * @param createBoundingBox defines if bounding box should be created for this submesh
  20585. */
  20586. constructor(
  20587. /** the material index to use */
  20588. materialIndex: number,
  20589. /** vertex index start */
  20590. verticesStart: number,
  20591. /** vertices count */
  20592. verticesCount: number,
  20593. /** index start */
  20594. indexStart: number,
  20595. /** indices count */
  20596. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20597. /**
  20598. * Returns true if this submesh covers the entire parent mesh
  20599. * @ignorenaming
  20600. */
  20601. readonly IsGlobal: boolean;
  20602. /**
  20603. * Returns the submesh BoudingInfo object
  20604. * @returns current bounding info (or mesh's one if the submesh is global)
  20605. */
  20606. getBoundingInfo(): BoundingInfo;
  20607. /**
  20608. * Sets the submesh BoundingInfo
  20609. * @param boundingInfo defines the new bounding info to use
  20610. * @returns the SubMesh
  20611. */
  20612. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20613. /**
  20614. * Returns the mesh of the current submesh
  20615. * @return the parent mesh
  20616. */
  20617. getMesh(): AbstractMesh;
  20618. /**
  20619. * Returns the rendering mesh of the submesh
  20620. * @returns the rendering mesh (could be different from parent mesh)
  20621. */
  20622. getRenderingMesh(): Mesh;
  20623. /**
  20624. * Returns the submesh material
  20625. * @returns null or the current material
  20626. */
  20627. getMaterial(): Nullable<Material>;
  20628. /**
  20629. * Sets a new updated BoundingInfo object to the submesh
  20630. * @param data defines an optional position array to use to determine the bounding info
  20631. * @returns the SubMesh
  20632. */
  20633. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20634. /** @hidden */
  20635. _checkCollision(collider: Collider): boolean;
  20636. /**
  20637. * Updates the submesh BoundingInfo
  20638. * @param world defines the world matrix to use to update the bounding info
  20639. * @returns the submesh
  20640. */
  20641. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20642. /**
  20643. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20644. * @param frustumPlanes defines the frustum planes
  20645. * @returns true if the submesh is intersecting with the frustum
  20646. */
  20647. isInFrustum(frustumPlanes: Plane[]): boolean;
  20648. /**
  20649. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20650. * @param frustumPlanes defines the frustum planes
  20651. * @returns true if the submesh is inside the frustum
  20652. */
  20653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20654. /**
  20655. * Renders the submesh
  20656. * @param enableAlphaMode defines if alpha needs to be used
  20657. * @returns the submesh
  20658. */
  20659. render(enableAlphaMode: boolean): SubMesh;
  20660. /**
  20661. * @hidden
  20662. */
  20663. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20664. /**
  20665. * Checks if the submesh intersects with a ray
  20666. * @param ray defines the ray to test
  20667. * @returns true is the passed ray intersects the submesh bounding box
  20668. */
  20669. canIntersects(ray: Ray): boolean;
  20670. /**
  20671. * Intersects current submesh with a ray
  20672. * @param ray defines the ray to test
  20673. * @param positions defines mesh's positions array
  20674. * @param indices defines mesh's indices array
  20675. * @param fastCheck defines if only bounding info should be used
  20676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20677. * @returns intersection info or null if no intersection
  20678. */
  20679. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20680. /** @hidden */
  20681. private _intersectLines;
  20682. /** @hidden */
  20683. private _intersectUnIndexedLines;
  20684. /** @hidden */
  20685. private _intersectTriangles;
  20686. /** @hidden */
  20687. private _intersectUnIndexedTriangles;
  20688. /** @hidden */
  20689. _rebuild(): void;
  20690. /**
  20691. * Creates a new submesh from the passed mesh
  20692. * @param newMesh defines the new hosting mesh
  20693. * @param newRenderingMesh defines an optional rendering mesh
  20694. * @returns the new submesh
  20695. */
  20696. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20697. /**
  20698. * Release associated resources
  20699. */
  20700. dispose(): void;
  20701. /**
  20702. * Gets the class name
  20703. * @returns the string "SubMesh".
  20704. */
  20705. getClassName(): string;
  20706. /**
  20707. * Creates a new submesh from indices data
  20708. * @param materialIndex the index of the main mesh material
  20709. * @param startIndex the index where to start the copy in the mesh indices array
  20710. * @param indexCount the number of indices to copy then from the startIndex
  20711. * @param mesh the main mesh to create the submesh from
  20712. * @param renderingMesh the optional rendering mesh
  20713. * @returns a new submesh
  20714. */
  20715. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20716. }
  20717. }
  20718. declare module BABYLON {
  20719. /**
  20720. * Class used to represent data loading progression
  20721. */
  20722. export class SceneLoaderFlags {
  20723. private static _ForceFullSceneLoadingForIncremental;
  20724. private static _ShowLoadingScreen;
  20725. private static _CleanBoneMatrixWeights;
  20726. private static _loggingLevel;
  20727. /**
  20728. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20729. */
  20730. static ForceFullSceneLoadingForIncremental: boolean;
  20731. /**
  20732. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20733. */
  20734. static ShowLoadingScreen: boolean;
  20735. /**
  20736. * Defines the current logging level (while loading the scene)
  20737. * @ignorenaming
  20738. */
  20739. static loggingLevel: number;
  20740. /**
  20741. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20742. */
  20743. static CleanBoneMatrixWeights: boolean;
  20744. }
  20745. }
  20746. declare module BABYLON {
  20747. /**
  20748. * Class used to store geometry data (vertex buffers + index buffer)
  20749. */
  20750. export class Geometry implements IGetSetVerticesData {
  20751. /**
  20752. * Gets or sets the ID of the geometry
  20753. */
  20754. id: string;
  20755. /**
  20756. * Gets or sets the unique ID of the geometry
  20757. */
  20758. uniqueId: number;
  20759. /**
  20760. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20761. */
  20762. delayLoadState: number;
  20763. /**
  20764. * Gets the file containing the data to load when running in delay load state
  20765. */
  20766. delayLoadingFile: Nullable<string>;
  20767. /**
  20768. * Callback called when the geometry is updated
  20769. */
  20770. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20771. private _scene;
  20772. private _engine;
  20773. private _meshes;
  20774. private _totalVertices;
  20775. /** @hidden */
  20776. _indices: IndicesArray;
  20777. /** @hidden */
  20778. _vertexBuffers: {
  20779. [key: string]: VertexBuffer;
  20780. };
  20781. private _isDisposed;
  20782. private _extend;
  20783. private _boundingBias;
  20784. /** @hidden */
  20785. _delayInfo: Array<string>;
  20786. private _indexBuffer;
  20787. private _indexBufferIsUpdatable;
  20788. /** @hidden */
  20789. _boundingInfo: Nullable<BoundingInfo>;
  20790. /** @hidden */
  20791. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20792. /** @hidden */
  20793. _softwareSkinningFrameId: number;
  20794. private _vertexArrayObjects;
  20795. private _updatable;
  20796. /** @hidden */
  20797. _positions: Nullable<Vector3[]>;
  20798. /**
  20799. * 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
  20800. */
  20801. /**
  20802. * 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
  20803. */
  20804. boundingBias: Vector2;
  20805. /**
  20806. * Static function used to attach a new empty geometry to a mesh
  20807. * @param mesh defines the mesh to attach the geometry to
  20808. * @returns the new Geometry
  20809. */
  20810. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20811. /**
  20812. * Creates a new geometry
  20813. * @param id defines the unique ID
  20814. * @param scene defines the hosting scene
  20815. * @param vertexData defines the VertexData used to get geometry data
  20816. * @param updatable defines if geometry must be updatable (false by default)
  20817. * @param mesh defines the mesh that will be associated with the geometry
  20818. */
  20819. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20820. /**
  20821. * Gets the current extend of the geometry
  20822. */
  20823. readonly extend: {
  20824. minimum: Vector3;
  20825. maximum: Vector3;
  20826. };
  20827. /**
  20828. * Gets the hosting scene
  20829. * @returns the hosting Scene
  20830. */
  20831. getScene(): Scene;
  20832. /**
  20833. * Gets the hosting engine
  20834. * @returns the hosting Engine
  20835. */
  20836. getEngine(): Engine;
  20837. /**
  20838. * Defines if the geometry is ready to use
  20839. * @returns true if the geometry is ready to be used
  20840. */
  20841. isReady(): boolean;
  20842. /**
  20843. * Gets a value indicating that the geometry should not be serialized
  20844. */
  20845. readonly doNotSerialize: boolean;
  20846. /** @hidden */
  20847. _rebuild(): void;
  20848. /**
  20849. * Affects all geometry data in one call
  20850. * @param vertexData defines the geometry data
  20851. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20852. */
  20853. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20854. /**
  20855. * Set specific vertex data
  20856. * @param kind defines the data kind (Position, normal, etc...)
  20857. * @param data defines the vertex data to use
  20858. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20859. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20860. */
  20861. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20862. /**
  20863. * Removes a specific vertex data
  20864. * @param kind defines the data kind (Position, normal, etc...)
  20865. */
  20866. removeVerticesData(kind: string): void;
  20867. /**
  20868. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20869. * @param buffer defines the vertex buffer to use
  20870. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20871. */
  20872. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20873. /**
  20874. * Update a specific vertex buffer
  20875. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20876. * It will do nothing if the buffer is not updatable
  20877. * @param kind defines the data kind (Position, normal, etc...)
  20878. * @param data defines the data to use
  20879. * @param offset defines the offset in the target buffer where to store the data
  20880. * @param useBytes set to true if the offset is in bytes
  20881. */
  20882. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20883. /**
  20884. * Update a specific vertex buffer
  20885. * This function will create a new buffer if the current one is not updatable
  20886. * @param kind defines the data kind (Position, normal, etc...)
  20887. * @param data defines the data to use
  20888. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20889. */
  20890. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20891. private _updateBoundingInfo;
  20892. /** @hidden */
  20893. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20894. /**
  20895. * Gets total number of vertices
  20896. * @returns the total number of vertices
  20897. */
  20898. getTotalVertices(): number;
  20899. /**
  20900. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20901. * @param kind defines the data kind (Position, normal, etc...)
  20902. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20904. * @returns a float array containing vertex data
  20905. */
  20906. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20907. /**
  20908. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20909. * @param kind defines the data kind (Position, normal, etc...)
  20910. * @returns true if the vertex buffer with the specified kind is updatable
  20911. */
  20912. isVertexBufferUpdatable(kind: string): boolean;
  20913. /**
  20914. * Gets a specific vertex buffer
  20915. * @param kind defines the data kind (Position, normal, etc...)
  20916. * @returns a VertexBuffer
  20917. */
  20918. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20919. /**
  20920. * Returns all vertex buffers
  20921. * @return an object holding all vertex buffers indexed by kind
  20922. */
  20923. getVertexBuffers(): Nullable<{
  20924. [key: string]: VertexBuffer;
  20925. }>;
  20926. /**
  20927. * Gets a boolean indicating if specific vertex buffer is present
  20928. * @param kind defines the data kind (Position, normal, etc...)
  20929. * @returns true if data is present
  20930. */
  20931. isVerticesDataPresent(kind: string): boolean;
  20932. /**
  20933. * Gets a list of all attached data kinds (Position, normal, etc...)
  20934. * @returns a list of string containing all kinds
  20935. */
  20936. getVerticesDataKinds(): string[];
  20937. /**
  20938. * Update index buffer
  20939. * @param indices defines the indices to store in the index buffer
  20940. * @param offset defines the offset in the target buffer where to store the data
  20941. * @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)
  20942. */
  20943. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20944. /**
  20945. * Creates a new index buffer
  20946. * @param indices defines the indices to store in the index buffer
  20947. * @param totalVertices defines the total number of vertices (could be null)
  20948. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20949. */
  20950. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20951. /**
  20952. * Return the total number of indices
  20953. * @returns the total number of indices
  20954. */
  20955. getTotalIndices(): number;
  20956. /**
  20957. * Gets the index buffer array
  20958. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20959. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20960. * @returns the index buffer array
  20961. */
  20962. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20963. /**
  20964. * Gets the index buffer
  20965. * @return the index buffer
  20966. */
  20967. getIndexBuffer(): Nullable<DataBuffer>;
  20968. /** @hidden */
  20969. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20970. /**
  20971. * Release the associated resources for a specific mesh
  20972. * @param mesh defines the source mesh
  20973. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20974. */
  20975. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20976. /**
  20977. * Apply current geometry to a given mesh
  20978. * @param mesh defines the mesh to apply geometry to
  20979. */
  20980. applyToMesh(mesh: Mesh): void;
  20981. private _updateExtend;
  20982. private _applyToMesh;
  20983. private notifyUpdate;
  20984. /**
  20985. * Load the geometry if it was flagged as delay loaded
  20986. * @param scene defines the hosting scene
  20987. * @param onLoaded defines a callback called when the geometry is loaded
  20988. */
  20989. load(scene: Scene, onLoaded?: () => void): void;
  20990. private _queueLoad;
  20991. /**
  20992. * Invert the geometry to move from a right handed system to a left handed one.
  20993. */
  20994. toLeftHanded(): void;
  20995. /** @hidden */
  20996. _resetPointsArrayCache(): void;
  20997. /** @hidden */
  20998. _generatePointsArray(): boolean;
  20999. /**
  21000. * Gets a value indicating if the geometry is disposed
  21001. * @returns true if the geometry was disposed
  21002. */
  21003. isDisposed(): boolean;
  21004. private _disposeVertexArrayObjects;
  21005. /**
  21006. * Free all associated resources
  21007. */
  21008. dispose(): void;
  21009. /**
  21010. * Clone the current geometry into a new geometry
  21011. * @param id defines the unique ID of the new geometry
  21012. * @returns a new geometry object
  21013. */
  21014. copy(id: string): Geometry;
  21015. /**
  21016. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21017. * @return a JSON representation of the current geometry data (without the vertices data)
  21018. */
  21019. serialize(): any;
  21020. private toNumberArray;
  21021. /**
  21022. * Serialize all vertices data into a JSON oject
  21023. * @returns a JSON representation of the current geometry data
  21024. */
  21025. serializeVerticeData(): any;
  21026. /**
  21027. * Extracts a clone of a mesh geometry
  21028. * @param mesh defines the source mesh
  21029. * @param id defines the unique ID of the new geometry object
  21030. * @returns the new geometry object
  21031. */
  21032. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21033. /**
  21034. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21035. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21036. * Be aware Math.random() could cause collisions, but:
  21037. * "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"
  21038. * @returns a string containing a new GUID
  21039. */
  21040. static RandomId(): string;
  21041. /** @hidden */
  21042. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21043. private static _CleanMatricesWeights;
  21044. /**
  21045. * Create a new geometry from persisted data (Using .babylon file format)
  21046. * @param parsedVertexData defines the persisted data
  21047. * @param scene defines the hosting scene
  21048. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21049. * @returns the new geometry object
  21050. */
  21051. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21052. }
  21053. }
  21054. declare module BABYLON {
  21055. /**
  21056. * Define an interface for all classes that will get and set the data on vertices
  21057. */
  21058. export interface IGetSetVerticesData {
  21059. /**
  21060. * Gets a boolean indicating if specific vertex data is present
  21061. * @param kind defines the vertex data kind to use
  21062. * @returns true is data kind is present
  21063. */
  21064. isVerticesDataPresent(kind: string): boolean;
  21065. /**
  21066. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21067. * @param kind defines the data kind (Position, normal, etc...)
  21068. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21069. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21070. * @returns a float array containing vertex data
  21071. */
  21072. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21073. /**
  21074. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21075. * @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.
  21076. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21077. * @returns the indices array or an empty array if the mesh has no geometry
  21078. */
  21079. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21080. /**
  21081. * Set specific vertex data
  21082. * @param kind defines the data kind (Position, normal, etc...)
  21083. * @param data defines the vertex data to use
  21084. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21085. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21086. */
  21087. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21088. /**
  21089. * Update a specific associated vertex buffer
  21090. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21091. * - VertexBuffer.PositionKind
  21092. * - VertexBuffer.UVKind
  21093. * - VertexBuffer.UV2Kind
  21094. * - VertexBuffer.UV3Kind
  21095. * - VertexBuffer.UV4Kind
  21096. * - VertexBuffer.UV5Kind
  21097. * - VertexBuffer.UV6Kind
  21098. * - VertexBuffer.ColorKind
  21099. * - VertexBuffer.MatricesIndicesKind
  21100. * - VertexBuffer.MatricesIndicesExtraKind
  21101. * - VertexBuffer.MatricesWeightsKind
  21102. * - VertexBuffer.MatricesWeightsExtraKind
  21103. * @param data defines the data source
  21104. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21105. * @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)
  21106. */
  21107. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21108. /**
  21109. * Creates a new index buffer
  21110. * @param indices defines the indices to store in the index buffer
  21111. * @param totalVertices defines the total number of vertices (could be null)
  21112. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21113. */
  21114. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21115. }
  21116. /**
  21117. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21118. */
  21119. export class VertexData {
  21120. /**
  21121. * Mesh side orientation : usually the external or front surface
  21122. */
  21123. static readonly FRONTSIDE: number;
  21124. /**
  21125. * Mesh side orientation : usually the internal or back surface
  21126. */
  21127. static readonly BACKSIDE: number;
  21128. /**
  21129. * Mesh side orientation : both internal and external or front and back surfaces
  21130. */
  21131. static readonly DOUBLESIDE: number;
  21132. /**
  21133. * Mesh side orientation : by default, `FRONTSIDE`
  21134. */
  21135. static readonly DEFAULTSIDE: number;
  21136. /**
  21137. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21138. */
  21139. positions: Nullable<FloatArray>;
  21140. /**
  21141. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21142. */
  21143. normals: Nullable<FloatArray>;
  21144. /**
  21145. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21146. */
  21147. tangents: Nullable<FloatArray>;
  21148. /**
  21149. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21150. */
  21151. uvs: Nullable<FloatArray>;
  21152. /**
  21153. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21154. */
  21155. uvs2: Nullable<FloatArray>;
  21156. /**
  21157. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21158. */
  21159. uvs3: Nullable<FloatArray>;
  21160. /**
  21161. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21162. */
  21163. uvs4: Nullable<FloatArray>;
  21164. /**
  21165. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21166. */
  21167. uvs5: Nullable<FloatArray>;
  21168. /**
  21169. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21170. */
  21171. uvs6: Nullable<FloatArray>;
  21172. /**
  21173. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21174. */
  21175. colors: Nullable<FloatArray>;
  21176. /**
  21177. * 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).
  21178. */
  21179. matricesIndices: Nullable<FloatArray>;
  21180. /**
  21181. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21182. */
  21183. matricesWeights: Nullable<FloatArray>;
  21184. /**
  21185. * An array extending the number of possible indices
  21186. */
  21187. matricesIndicesExtra: Nullable<FloatArray>;
  21188. /**
  21189. * An array extending the number of possible weights when the number of indices is extended
  21190. */
  21191. matricesWeightsExtra: Nullable<FloatArray>;
  21192. /**
  21193. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21194. */
  21195. indices: Nullable<IndicesArray>;
  21196. /**
  21197. * Uses the passed data array to set the set the values for the specified kind of data
  21198. * @param data a linear array of floating numbers
  21199. * @param kind the type of data that is being set, eg positions, colors etc
  21200. */
  21201. set(data: FloatArray, kind: string): void;
  21202. /**
  21203. * Associates the vertexData to the passed Mesh.
  21204. * Sets it as updatable or not (default `false`)
  21205. * @param mesh the mesh the vertexData is applied to
  21206. * @param updatable when used and having the value true allows new data to update the vertexData
  21207. * @returns the VertexData
  21208. */
  21209. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21210. /**
  21211. * Associates the vertexData to the passed Geometry.
  21212. * Sets it as updatable or not (default `false`)
  21213. * @param geometry the geometry the vertexData is applied to
  21214. * @param updatable when used and having the value true allows new data to update the vertexData
  21215. * @returns VertexData
  21216. */
  21217. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21218. /**
  21219. * Updates the associated mesh
  21220. * @param mesh the mesh to be updated
  21221. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21222. * @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
  21223. * @returns VertexData
  21224. */
  21225. updateMesh(mesh: Mesh): VertexData;
  21226. /**
  21227. * Updates the associated geometry
  21228. * @param geometry the geometry to be updated
  21229. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21230. * @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
  21231. * @returns VertexData.
  21232. */
  21233. updateGeometry(geometry: Geometry): VertexData;
  21234. private _applyTo;
  21235. private _update;
  21236. /**
  21237. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21238. * @param matrix the transforming matrix
  21239. * @returns the VertexData
  21240. */
  21241. transform(matrix: Matrix): VertexData;
  21242. /**
  21243. * Merges the passed VertexData into the current one
  21244. * @param other the VertexData to be merged into the current one
  21245. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21246. * @returns the modified VertexData
  21247. */
  21248. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21249. private _mergeElement;
  21250. private _validate;
  21251. /**
  21252. * Serializes the VertexData
  21253. * @returns a serialized object
  21254. */
  21255. serialize(): any;
  21256. /**
  21257. * Extracts the vertexData from a mesh
  21258. * @param mesh the mesh from which to extract the VertexData
  21259. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21260. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21261. * @returns the object VertexData associated to the passed mesh
  21262. */
  21263. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21264. /**
  21265. * Extracts the vertexData from the geometry
  21266. * @param geometry the geometry from which to extract the VertexData
  21267. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21268. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21269. * @returns the object VertexData associated to the passed mesh
  21270. */
  21271. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21272. private static _ExtractFrom;
  21273. /**
  21274. * Creates the VertexData for a Ribbon
  21275. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21276. * * pathArray array of paths, each of which an array of successive Vector3
  21277. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21278. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21279. * * 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
  21280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21281. * * 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)
  21282. * * 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)
  21283. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21284. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21285. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21286. * @returns the VertexData of the ribbon
  21287. */
  21288. static CreateRibbon(options: {
  21289. pathArray: Vector3[][];
  21290. closeArray?: boolean;
  21291. closePath?: boolean;
  21292. offset?: number;
  21293. sideOrientation?: number;
  21294. frontUVs?: Vector4;
  21295. backUVs?: Vector4;
  21296. invertUV?: boolean;
  21297. uvs?: Vector2[];
  21298. colors?: Color4[];
  21299. }): VertexData;
  21300. /**
  21301. * Creates the VertexData for a box
  21302. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21303. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21304. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21305. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21306. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21307. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21308. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21310. * * 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)
  21311. * * 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)
  21312. * @returns the VertexData of the box
  21313. */
  21314. static CreateBox(options: {
  21315. size?: number;
  21316. width?: number;
  21317. height?: number;
  21318. depth?: number;
  21319. faceUV?: Vector4[];
  21320. faceColors?: Color4[];
  21321. sideOrientation?: number;
  21322. frontUVs?: Vector4;
  21323. backUVs?: Vector4;
  21324. }): VertexData;
  21325. /**
  21326. * Creates the VertexData for a tiled box
  21327. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21328. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21329. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21330. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21332. * @returns the VertexData of the box
  21333. */
  21334. static CreateTiledBox(options: {
  21335. pattern?: number;
  21336. width?: number;
  21337. height?: number;
  21338. depth?: number;
  21339. tileSize?: number;
  21340. tileWidth?: number;
  21341. tileHeight?: number;
  21342. alignHorizontal?: number;
  21343. alignVertical?: number;
  21344. faceUV?: Vector4[];
  21345. faceColors?: Color4[];
  21346. sideOrientation?: number;
  21347. }): VertexData;
  21348. /**
  21349. * Creates the VertexData for a tiled plane
  21350. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21351. * * pattern a limited pattern arrangement depending on the number
  21352. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21353. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21354. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21356. * * 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)
  21357. * * 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)
  21358. * @returns the VertexData of the tiled plane
  21359. */
  21360. static CreateTiledPlane(options: {
  21361. pattern?: number;
  21362. tileSize?: number;
  21363. tileWidth?: number;
  21364. tileHeight?: number;
  21365. size?: number;
  21366. width?: number;
  21367. height?: number;
  21368. alignHorizontal?: number;
  21369. alignVertical?: number;
  21370. sideOrientation?: number;
  21371. frontUVs?: Vector4;
  21372. backUVs?: Vector4;
  21373. }): VertexData;
  21374. /**
  21375. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21376. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21377. * * segments sets the number of horizontal strips optional, default 32
  21378. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21379. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21380. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21381. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21382. * * 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
  21383. * * 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
  21384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21385. * * 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)
  21386. * * 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)
  21387. * @returns the VertexData of the ellipsoid
  21388. */
  21389. static CreateSphere(options: {
  21390. segments?: number;
  21391. diameter?: number;
  21392. diameterX?: number;
  21393. diameterY?: number;
  21394. diameterZ?: number;
  21395. arc?: number;
  21396. slice?: number;
  21397. sideOrientation?: number;
  21398. frontUVs?: Vector4;
  21399. backUVs?: Vector4;
  21400. }): VertexData;
  21401. /**
  21402. * Creates the VertexData for a cylinder, cone or prism
  21403. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21404. * * height sets the height (y direction) of the cylinder, optional, default 2
  21405. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21406. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21407. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21408. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21409. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21410. * * 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
  21411. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21412. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21413. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21414. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21416. * * 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)
  21417. * * 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)
  21418. * @returns the VertexData of the cylinder, cone or prism
  21419. */
  21420. static CreateCylinder(options: {
  21421. height?: number;
  21422. diameterTop?: number;
  21423. diameterBottom?: number;
  21424. diameter?: number;
  21425. tessellation?: number;
  21426. subdivisions?: number;
  21427. arc?: number;
  21428. faceColors?: Color4[];
  21429. faceUV?: Vector4[];
  21430. hasRings?: boolean;
  21431. enclose?: boolean;
  21432. sideOrientation?: number;
  21433. frontUVs?: Vector4;
  21434. backUVs?: Vector4;
  21435. }): VertexData;
  21436. /**
  21437. * Creates the VertexData for a torus
  21438. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21439. * * diameter the diameter of the torus, optional default 1
  21440. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21441. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21443. * * 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)
  21444. * * 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)
  21445. * @returns the VertexData of the torus
  21446. */
  21447. static CreateTorus(options: {
  21448. diameter?: number;
  21449. thickness?: number;
  21450. tessellation?: number;
  21451. sideOrientation?: number;
  21452. frontUVs?: Vector4;
  21453. backUVs?: Vector4;
  21454. }): VertexData;
  21455. /**
  21456. * Creates the VertexData of the LineSystem
  21457. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21458. * - lines an array of lines, each line being an array of successive Vector3
  21459. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21460. * @returns the VertexData of the LineSystem
  21461. */
  21462. static CreateLineSystem(options: {
  21463. lines: Vector3[][];
  21464. colors?: Nullable<Color4[][]>;
  21465. }): VertexData;
  21466. /**
  21467. * Create the VertexData for a DashedLines
  21468. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21469. * - points an array successive Vector3
  21470. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21471. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21472. * - dashNb the intended total number of dashes, optional, default 200
  21473. * @returns the VertexData for the DashedLines
  21474. */
  21475. static CreateDashedLines(options: {
  21476. points: Vector3[];
  21477. dashSize?: number;
  21478. gapSize?: number;
  21479. dashNb?: number;
  21480. }): VertexData;
  21481. /**
  21482. * Creates the VertexData for a Ground
  21483. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21484. * - width the width (x direction) of the ground, optional, default 1
  21485. * - height the height (z direction) of the ground, optional, default 1
  21486. * - subdivisions the number of subdivisions per side, optional, default 1
  21487. * @returns the VertexData of the Ground
  21488. */
  21489. static CreateGround(options: {
  21490. width?: number;
  21491. height?: number;
  21492. subdivisions?: number;
  21493. subdivisionsX?: number;
  21494. subdivisionsY?: number;
  21495. }): VertexData;
  21496. /**
  21497. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21498. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21499. * * xmin the ground minimum X coordinate, optional, default -1
  21500. * * zmin the ground minimum Z coordinate, optional, default -1
  21501. * * xmax the ground maximum X coordinate, optional, default 1
  21502. * * zmax the ground maximum Z coordinate, optional, default 1
  21503. * * 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}
  21504. * * 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}
  21505. * @returns the VertexData of the TiledGround
  21506. */
  21507. static CreateTiledGround(options: {
  21508. xmin: number;
  21509. zmin: number;
  21510. xmax: number;
  21511. zmax: number;
  21512. subdivisions?: {
  21513. w: number;
  21514. h: number;
  21515. };
  21516. precision?: {
  21517. w: number;
  21518. h: number;
  21519. };
  21520. }): VertexData;
  21521. /**
  21522. * Creates the VertexData of the Ground designed from a heightmap
  21523. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21524. * * width the width (x direction) of the ground
  21525. * * height the height (z direction) of the ground
  21526. * * subdivisions the number of subdivisions per side
  21527. * * minHeight the minimum altitude on the ground, optional, default 0
  21528. * * maxHeight the maximum altitude on the ground, optional default 1
  21529. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21530. * * buffer the array holding the image color data
  21531. * * bufferWidth the width of image
  21532. * * bufferHeight the height of image
  21533. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21534. * @returns the VertexData of the Ground designed from a heightmap
  21535. */
  21536. static CreateGroundFromHeightMap(options: {
  21537. width: number;
  21538. height: number;
  21539. subdivisions: number;
  21540. minHeight: number;
  21541. maxHeight: number;
  21542. colorFilter: Color3;
  21543. buffer: Uint8Array;
  21544. bufferWidth: number;
  21545. bufferHeight: number;
  21546. alphaFilter: number;
  21547. }): VertexData;
  21548. /**
  21549. * Creates the VertexData for a Plane
  21550. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21551. * * size sets the width and height of the plane to the value of size, optional default 1
  21552. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21553. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21555. * * 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)
  21556. * * 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)
  21557. * @returns the VertexData of the box
  21558. */
  21559. static CreatePlane(options: {
  21560. size?: number;
  21561. width?: number;
  21562. height?: number;
  21563. sideOrientation?: number;
  21564. frontUVs?: Vector4;
  21565. backUVs?: Vector4;
  21566. }): VertexData;
  21567. /**
  21568. * Creates the VertexData of the Disc or regular Polygon
  21569. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21570. * * radius the radius of the disc, optional default 0.5
  21571. * * tessellation the number of polygon sides, optional, default 64
  21572. * * 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
  21573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21574. * * 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)
  21575. * * 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)
  21576. * @returns the VertexData of the box
  21577. */
  21578. static CreateDisc(options: {
  21579. radius?: number;
  21580. tessellation?: number;
  21581. arc?: number;
  21582. sideOrientation?: number;
  21583. frontUVs?: Vector4;
  21584. backUVs?: Vector4;
  21585. }): VertexData;
  21586. /**
  21587. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21588. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21589. * @param polygon a mesh built from polygonTriangulation.build()
  21590. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21591. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21592. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21593. * @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)
  21594. * @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)
  21595. * @returns the VertexData of the Polygon
  21596. */
  21597. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21598. /**
  21599. * Creates the VertexData of the IcoSphere
  21600. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21601. * * radius the radius of the IcoSphere, optional default 1
  21602. * * radiusX allows stretching in the x direction, optional, default radius
  21603. * * radiusY allows stretching in the y direction, optional, default radius
  21604. * * radiusZ allows stretching in the z direction, optional, default radius
  21605. * * flat when true creates a flat shaded mesh, optional, default true
  21606. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21608. * * 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)
  21609. * * 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)
  21610. * @returns the VertexData of the IcoSphere
  21611. */
  21612. static CreateIcoSphere(options: {
  21613. radius?: number;
  21614. radiusX?: number;
  21615. radiusY?: number;
  21616. radiusZ?: number;
  21617. flat?: boolean;
  21618. subdivisions?: number;
  21619. sideOrientation?: number;
  21620. frontUVs?: Vector4;
  21621. backUVs?: Vector4;
  21622. }): VertexData;
  21623. /**
  21624. * Creates the VertexData for a Polyhedron
  21625. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21626. * * type provided types are:
  21627. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21628. * * 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)
  21629. * * size the size of the IcoSphere, optional default 1
  21630. * * sizeX allows stretching in the x direction, optional, default size
  21631. * * sizeY allows stretching in the y direction, optional, default size
  21632. * * sizeZ allows stretching in the z direction, optional, default size
  21633. * * 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
  21634. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21635. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21636. * * flat when true creates a flat shaded mesh, optional, default true
  21637. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21639. * * 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)
  21640. * * 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)
  21641. * @returns the VertexData of the Polyhedron
  21642. */
  21643. static CreatePolyhedron(options: {
  21644. type?: number;
  21645. size?: number;
  21646. sizeX?: number;
  21647. sizeY?: number;
  21648. sizeZ?: number;
  21649. custom?: any;
  21650. faceUV?: Vector4[];
  21651. faceColors?: Color4[];
  21652. flat?: boolean;
  21653. sideOrientation?: number;
  21654. frontUVs?: Vector4;
  21655. backUVs?: Vector4;
  21656. }): VertexData;
  21657. /**
  21658. * Creates the VertexData for a TorusKnot
  21659. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21660. * * radius the radius of the torus knot, optional, default 2
  21661. * * tube the thickness of the tube, optional, default 0.5
  21662. * * radialSegments the number of sides on each tube segments, optional, default 32
  21663. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21664. * * p the number of windings around the z axis, optional, default 2
  21665. * * q the number of windings around the x axis, optional, default 3
  21666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21667. * * 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)
  21668. * * 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)
  21669. * @returns the VertexData of the Torus Knot
  21670. */
  21671. static CreateTorusKnot(options: {
  21672. radius?: number;
  21673. tube?: number;
  21674. radialSegments?: number;
  21675. tubularSegments?: number;
  21676. p?: number;
  21677. q?: number;
  21678. sideOrientation?: number;
  21679. frontUVs?: Vector4;
  21680. backUVs?: Vector4;
  21681. }): VertexData;
  21682. /**
  21683. * Compute normals for given positions and indices
  21684. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21685. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21686. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21687. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21688. * * facetNormals : optional array of facet normals (vector3)
  21689. * * facetPositions : optional array of facet positions (vector3)
  21690. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21691. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21692. * * bInfo : optional bounding info, required for facetPartitioning computation
  21693. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21694. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21695. * * useRightHandedSystem: optional boolean to for right handed system computation
  21696. * * depthSort : optional boolean to enable the facet depth sort computation
  21697. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21698. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21699. */
  21700. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21701. facetNormals?: any;
  21702. facetPositions?: any;
  21703. facetPartitioning?: any;
  21704. ratio?: number;
  21705. bInfo?: any;
  21706. bbSize?: Vector3;
  21707. subDiv?: any;
  21708. useRightHandedSystem?: boolean;
  21709. depthSort?: boolean;
  21710. distanceTo?: Vector3;
  21711. depthSortedFacets?: any;
  21712. }): void;
  21713. /** @hidden */
  21714. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21715. /**
  21716. * Applies VertexData created from the imported parameters to the geometry
  21717. * @param parsedVertexData the parsed data from an imported file
  21718. * @param geometry the geometry to apply the VertexData to
  21719. */
  21720. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21721. }
  21722. }
  21723. declare module BABYLON {
  21724. /**
  21725. * Defines a target to use with MorphTargetManager
  21726. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21727. */
  21728. export class MorphTarget implements IAnimatable {
  21729. /** defines the name of the target */
  21730. name: string;
  21731. /**
  21732. * Gets or sets the list of animations
  21733. */
  21734. animations: Animation[];
  21735. private _scene;
  21736. private _positions;
  21737. private _normals;
  21738. private _tangents;
  21739. private _uvs;
  21740. private _influence;
  21741. /**
  21742. * Observable raised when the influence changes
  21743. */
  21744. onInfluenceChanged: Observable<boolean>;
  21745. /** @hidden */
  21746. _onDataLayoutChanged: Observable<void>;
  21747. /**
  21748. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21749. */
  21750. influence: number;
  21751. /**
  21752. * Gets or sets the id of the morph Target
  21753. */
  21754. id: string;
  21755. private _animationPropertiesOverride;
  21756. /**
  21757. * Gets or sets the animation properties override
  21758. */
  21759. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21760. /**
  21761. * Creates a new MorphTarget
  21762. * @param name defines the name of the target
  21763. * @param influence defines the influence to use
  21764. * @param scene defines the scene the morphtarget belongs to
  21765. */
  21766. constructor(
  21767. /** defines the name of the target */
  21768. name: string, influence?: number, scene?: Nullable<Scene>);
  21769. /**
  21770. * Gets a boolean defining if the target contains position data
  21771. */
  21772. readonly hasPositions: boolean;
  21773. /**
  21774. * Gets a boolean defining if the target contains normal data
  21775. */
  21776. readonly hasNormals: boolean;
  21777. /**
  21778. * Gets a boolean defining if the target contains tangent data
  21779. */
  21780. readonly hasTangents: boolean;
  21781. /**
  21782. * Gets a boolean defining if the target contains texture coordinates data
  21783. */
  21784. readonly hasUVs: boolean;
  21785. /**
  21786. * Affects position data to this target
  21787. * @param data defines the position data to use
  21788. */
  21789. setPositions(data: Nullable<FloatArray>): void;
  21790. /**
  21791. * Gets the position data stored in this target
  21792. * @returns a FloatArray containing the position data (or null if not present)
  21793. */
  21794. getPositions(): Nullable<FloatArray>;
  21795. /**
  21796. * Affects normal data to this target
  21797. * @param data defines the normal data to use
  21798. */
  21799. setNormals(data: Nullable<FloatArray>): void;
  21800. /**
  21801. * Gets the normal data stored in this target
  21802. * @returns a FloatArray containing the normal data (or null if not present)
  21803. */
  21804. getNormals(): Nullable<FloatArray>;
  21805. /**
  21806. * Affects tangent data to this target
  21807. * @param data defines the tangent data to use
  21808. */
  21809. setTangents(data: Nullable<FloatArray>): void;
  21810. /**
  21811. * Gets the tangent data stored in this target
  21812. * @returns a FloatArray containing the tangent data (or null if not present)
  21813. */
  21814. getTangents(): Nullable<FloatArray>;
  21815. /**
  21816. * Affects texture coordinates data to this target
  21817. * @param data defines the texture coordinates data to use
  21818. */
  21819. setUVs(data: Nullable<FloatArray>): void;
  21820. /**
  21821. * Gets the texture coordinates data stored in this target
  21822. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21823. */
  21824. getUVs(): Nullable<FloatArray>;
  21825. /**
  21826. * Serializes the current target into a Serialization object
  21827. * @returns the serialized object
  21828. */
  21829. serialize(): any;
  21830. /**
  21831. * Returns the string "MorphTarget"
  21832. * @returns "MorphTarget"
  21833. */
  21834. getClassName(): string;
  21835. /**
  21836. * Creates a new target from serialized data
  21837. * @param serializationObject defines the serialized data to use
  21838. * @returns a new MorphTarget
  21839. */
  21840. static Parse(serializationObject: any): MorphTarget;
  21841. /**
  21842. * Creates a MorphTarget from mesh data
  21843. * @param mesh defines the source mesh
  21844. * @param name defines the name to use for the new target
  21845. * @param influence defines the influence to attach to the target
  21846. * @returns a new MorphTarget
  21847. */
  21848. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21849. }
  21850. }
  21851. declare module BABYLON {
  21852. /**
  21853. * This class is used to deform meshes using morphing between different targets
  21854. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21855. */
  21856. export class MorphTargetManager {
  21857. private _targets;
  21858. private _targetInfluenceChangedObservers;
  21859. private _targetDataLayoutChangedObservers;
  21860. private _activeTargets;
  21861. private _scene;
  21862. private _influences;
  21863. private _supportsNormals;
  21864. private _supportsTangents;
  21865. private _supportsUVs;
  21866. private _vertexCount;
  21867. private _uniqueId;
  21868. private _tempInfluences;
  21869. /**
  21870. * Gets or sets a boolean indicating if normals must be morphed
  21871. */
  21872. enableNormalMorphing: boolean;
  21873. /**
  21874. * Gets or sets a boolean indicating if tangents must be morphed
  21875. */
  21876. enableTangentMorphing: boolean;
  21877. /**
  21878. * Gets or sets a boolean indicating if UV must be morphed
  21879. */
  21880. enableUVMorphing: boolean;
  21881. /**
  21882. * Creates a new MorphTargetManager
  21883. * @param scene defines the current scene
  21884. */
  21885. constructor(scene?: Nullable<Scene>);
  21886. /**
  21887. * Gets the unique ID of this manager
  21888. */
  21889. readonly uniqueId: number;
  21890. /**
  21891. * Gets the number of vertices handled by this manager
  21892. */
  21893. readonly vertexCount: number;
  21894. /**
  21895. * Gets a boolean indicating if this manager supports morphing of normals
  21896. */
  21897. readonly supportsNormals: boolean;
  21898. /**
  21899. * Gets a boolean indicating if this manager supports morphing of tangents
  21900. */
  21901. readonly supportsTangents: boolean;
  21902. /**
  21903. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21904. */
  21905. readonly supportsUVs: boolean;
  21906. /**
  21907. * Gets the number of targets stored in this manager
  21908. */
  21909. readonly numTargets: number;
  21910. /**
  21911. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21912. */
  21913. readonly numInfluencers: number;
  21914. /**
  21915. * Gets the list of influences (one per target)
  21916. */
  21917. readonly influences: Float32Array;
  21918. /**
  21919. * Gets the active target at specified index. An active target is a target with an influence > 0
  21920. * @param index defines the index to check
  21921. * @returns the requested target
  21922. */
  21923. getActiveTarget(index: number): MorphTarget;
  21924. /**
  21925. * Gets the target at specified index
  21926. * @param index defines the index to check
  21927. * @returns the requested target
  21928. */
  21929. getTarget(index: number): MorphTarget;
  21930. /**
  21931. * Add a new target to this manager
  21932. * @param target defines the target to add
  21933. */
  21934. addTarget(target: MorphTarget): void;
  21935. /**
  21936. * Removes a target from the manager
  21937. * @param target defines the target to remove
  21938. */
  21939. removeTarget(target: MorphTarget): void;
  21940. /**
  21941. * Serializes the current manager into a Serialization object
  21942. * @returns the serialized object
  21943. */
  21944. serialize(): any;
  21945. private _syncActiveTargets;
  21946. /**
  21947. * Syncrhonize the targets with all the meshes using this morph target manager
  21948. */
  21949. synchronize(): void;
  21950. /**
  21951. * Creates a new MorphTargetManager from serialized data
  21952. * @param serializationObject defines the serialized data
  21953. * @param scene defines the hosting scene
  21954. * @returns the new MorphTargetManager
  21955. */
  21956. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Class used to represent a specific level of detail of a mesh
  21962. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21963. */
  21964. export class MeshLODLevel {
  21965. /** Defines the distance where this level should star being displayed */
  21966. distance: number;
  21967. /** Defines the mesh to use to render this level */
  21968. mesh: Nullable<Mesh>;
  21969. /**
  21970. * Creates a new LOD level
  21971. * @param distance defines the distance where this level should star being displayed
  21972. * @param mesh defines the mesh to use to render this level
  21973. */
  21974. constructor(
  21975. /** Defines the distance where this level should star being displayed */
  21976. distance: number,
  21977. /** Defines the mesh to use to render this level */
  21978. mesh: Nullable<Mesh>);
  21979. }
  21980. }
  21981. declare module BABYLON {
  21982. /**
  21983. * Mesh representing the gorund
  21984. */
  21985. export class GroundMesh extends Mesh {
  21986. /** If octree should be generated */
  21987. generateOctree: boolean;
  21988. private _heightQuads;
  21989. /** @hidden */
  21990. _subdivisionsX: number;
  21991. /** @hidden */
  21992. _subdivisionsY: number;
  21993. /** @hidden */
  21994. _width: number;
  21995. /** @hidden */
  21996. _height: number;
  21997. /** @hidden */
  21998. _minX: number;
  21999. /** @hidden */
  22000. _maxX: number;
  22001. /** @hidden */
  22002. _minZ: number;
  22003. /** @hidden */
  22004. _maxZ: number;
  22005. constructor(name: string, scene: Scene);
  22006. /**
  22007. * "GroundMesh"
  22008. * @returns "GroundMesh"
  22009. */
  22010. getClassName(): string;
  22011. /**
  22012. * The minimum of x and y subdivisions
  22013. */
  22014. readonly subdivisions: number;
  22015. /**
  22016. * X subdivisions
  22017. */
  22018. readonly subdivisionsX: number;
  22019. /**
  22020. * Y subdivisions
  22021. */
  22022. readonly subdivisionsY: number;
  22023. /**
  22024. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22025. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22026. * @param chunksCount the number of subdivisions for x and y
  22027. * @param octreeBlocksSize (Default: 32)
  22028. */
  22029. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22030. /**
  22031. * Returns a height (y) value in the Worl system :
  22032. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22033. * @param x x coordinate
  22034. * @param z z coordinate
  22035. * @returns the ground y position if (x, z) are outside the ground surface.
  22036. */
  22037. getHeightAtCoordinates(x: number, z: number): number;
  22038. /**
  22039. * Returns a normalized vector (Vector3) orthogonal to the ground
  22040. * at the ground coordinates (x, z) expressed in the World system.
  22041. * @param x x coordinate
  22042. * @param z z coordinate
  22043. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22044. */
  22045. getNormalAtCoordinates(x: number, z: number): Vector3;
  22046. /**
  22047. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22048. * at the ground coordinates (x, z) expressed in the World system.
  22049. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22050. * @param x x coordinate
  22051. * @param z z coordinate
  22052. * @param ref vector to store the result
  22053. * @returns the GroundMesh.
  22054. */
  22055. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22056. /**
  22057. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22058. * if the ground has been updated.
  22059. * This can be used in the render loop.
  22060. * @returns the GroundMesh.
  22061. */
  22062. updateCoordinateHeights(): GroundMesh;
  22063. private _getFacetAt;
  22064. private _initHeightQuads;
  22065. private _computeHeightQuads;
  22066. /**
  22067. * Serializes this ground mesh
  22068. * @param serializationObject object to write serialization to
  22069. */
  22070. serialize(serializationObject: any): void;
  22071. /**
  22072. * Parses a serialized ground mesh
  22073. * @param parsedMesh the serialized mesh
  22074. * @param scene the scene to create the ground mesh in
  22075. * @returns the created ground mesh
  22076. */
  22077. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22078. }
  22079. }
  22080. declare module BABYLON {
  22081. /**
  22082. * Interface for Physics-Joint data
  22083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22084. */
  22085. export interface PhysicsJointData {
  22086. /**
  22087. * The main pivot of the joint
  22088. */
  22089. mainPivot?: Vector3;
  22090. /**
  22091. * The connected pivot of the joint
  22092. */
  22093. connectedPivot?: Vector3;
  22094. /**
  22095. * The main axis of the joint
  22096. */
  22097. mainAxis?: Vector3;
  22098. /**
  22099. * The connected axis of the joint
  22100. */
  22101. connectedAxis?: Vector3;
  22102. /**
  22103. * The collision of the joint
  22104. */
  22105. collision?: boolean;
  22106. /**
  22107. * Native Oimo/Cannon/Energy data
  22108. */
  22109. nativeParams?: any;
  22110. }
  22111. /**
  22112. * This is a holder class for the physics joint created by the physics plugin
  22113. * It holds a set of functions to control the underlying joint
  22114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22115. */
  22116. export class PhysicsJoint {
  22117. /**
  22118. * The type of the physics joint
  22119. */
  22120. type: number;
  22121. /**
  22122. * The data for the physics joint
  22123. */
  22124. jointData: PhysicsJointData;
  22125. private _physicsJoint;
  22126. protected _physicsPlugin: IPhysicsEnginePlugin;
  22127. /**
  22128. * Initializes the physics joint
  22129. * @param type The type of the physics joint
  22130. * @param jointData The data for the physics joint
  22131. */
  22132. constructor(
  22133. /**
  22134. * The type of the physics joint
  22135. */
  22136. type: number,
  22137. /**
  22138. * The data for the physics joint
  22139. */
  22140. jointData: PhysicsJointData);
  22141. /**
  22142. * Gets the physics joint
  22143. */
  22144. /**
  22145. * Sets the physics joint
  22146. */
  22147. physicsJoint: any;
  22148. /**
  22149. * Sets the physics plugin
  22150. */
  22151. physicsPlugin: IPhysicsEnginePlugin;
  22152. /**
  22153. * Execute a function that is physics-plugin specific.
  22154. * @param {Function} func the function that will be executed.
  22155. * It accepts two parameters: the physics world and the physics joint
  22156. */
  22157. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22158. /**
  22159. * Distance-Joint type
  22160. */
  22161. static DistanceJoint: number;
  22162. /**
  22163. * Hinge-Joint type
  22164. */
  22165. static HingeJoint: number;
  22166. /**
  22167. * Ball-and-Socket joint type
  22168. */
  22169. static BallAndSocketJoint: number;
  22170. /**
  22171. * Wheel-Joint type
  22172. */
  22173. static WheelJoint: number;
  22174. /**
  22175. * Slider-Joint type
  22176. */
  22177. static SliderJoint: number;
  22178. /**
  22179. * Prismatic-Joint type
  22180. */
  22181. static PrismaticJoint: number;
  22182. /**
  22183. * Universal-Joint type
  22184. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22185. */
  22186. static UniversalJoint: number;
  22187. /**
  22188. * Hinge-Joint 2 type
  22189. */
  22190. static Hinge2Joint: number;
  22191. /**
  22192. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22193. */
  22194. static PointToPointJoint: number;
  22195. /**
  22196. * Spring-Joint type
  22197. */
  22198. static SpringJoint: number;
  22199. /**
  22200. * Lock-Joint type
  22201. */
  22202. static LockJoint: number;
  22203. }
  22204. /**
  22205. * A class representing a physics distance joint
  22206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22207. */
  22208. export class DistanceJoint extends PhysicsJoint {
  22209. /**
  22210. *
  22211. * @param jointData The data for the Distance-Joint
  22212. */
  22213. constructor(jointData: DistanceJointData);
  22214. /**
  22215. * Update the predefined distance.
  22216. * @param maxDistance The maximum preferred distance
  22217. * @param minDistance The minimum preferred distance
  22218. */
  22219. updateDistance(maxDistance: number, minDistance?: number): void;
  22220. }
  22221. /**
  22222. * Represents a Motor-Enabled Joint
  22223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22224. */
  22225. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22226. /**
  22227. * Initializes the Motor-Enabled Joint
  22228. * @param type The type of the joint
  22229. * @param jointData The physica joint data for the joint
  22230. */
  22231. constructor(type: number, jointData: PhysicsJointData);
  22232. /**
  22233. * Set the motor values.
  22234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22235. * @param force the force to apply
  22236. * @param maxForce max force for this motor.
  22237. */
  22238. setMotor(force?: number, maxForce?: number): void;
  22239. /**
  22240. * Set the motor's limits.
  22241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22242. * @param upperLimit The upper limit of the motor
  22243. * @param lowerLimit The lower limit of the motor
  22244. */
  22245. setLimit(upperLimit: number, lowerLimit?: number): void;
  22246. }
  22247. /**
  22248. * This class represents a single physics Hinge-Joint
  22249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22250. */
  22251. export class HingeJoint extends MotorEnabledJoint {
  22252. /**
  22253. * Initializes the Hinge-Joint
  22254. * @param jointData The joint data for the Hinge-Joint
  22255. */
  22256. constructor(jointData: PhysicsJointData);
  22257. /**
  22258. * Set the motor values.
  22259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22260. * @param {number} force the force to apply
  22261. * @param {number} maxForce max force for this motor.
  22262. */
  22263. setMotor(force?: number, maxForce?: number): void;
  22264. /**
  22265. * Set the motor's limits.
  22266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22267. * @param upperLimit The upper limit of the motor
  22268. * @param lowerLimit The lower limit of the motor
  22269. */
  22270. setLimit(upperLimit: number, lowerLimit?: number): void;
  22271. }
  22272. /**
  22273. * This class represents a dual hinge physics joint (same as wheel joint)
  22274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22275. */
  22276. export class Hinge2Joint extends MotorEnabledJoint {
  22277. /**
  22278. * Initializes the Hinge2-Joint
  22279. * @param jointData The joint data for the Hinge2-Joint
  22280. */
  22281. constructor(jointData: PhysicsJointData);
  22282. /**
  22283. * Set the motor values.
  22284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22285. * @param {number} targetSpeed the speed the motor is to reach
  22286. * @param {number} maxForce max force for this motor.
  22287. * @param {motorIndex} the motor's index, 0 or 1.
  22288. */
  22289. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22290. /**
  22291. * Set the motor limits.
  22292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22293. * @param {number} upperLimit the upper limit
  22294. * @param {number} lowerLimit lower limit
  22295. * @param {motorIndex} the motor's index, 0 or 1.
  22296. */
  22297. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22298. }
  22299. /**
  22300. * Interface for a motor enabled joint
  22301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22302. */
  22303. export interface IMotorEnabledJoint {
  22304. /**
  22305. * Physics joint
  22306. */
  22307. physicsJoint: any;
  22308. /**
  22309. * Sets the motor of the motor-enabled joint
  22310. * @param force The force of the motor
  22311. * @param maxForce The maximum force of the motor
  22312. * @param motorIndex The index of the motor
  22313. */
  22314. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22315. /**
  22316. * Sets the limit of the motor
  22317. * @param upperLimit The upper limit of the motor
  22318. * @param lowerLimit The lower limit of the motor
  22319. * @param motorIndex The index of the motor
  22320. */
  22321. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22322. }
  22323. /**
  22324. * Joint data for a Distance-Joint
  22325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22326. */
  22327. export interface DistanceJointData extends PhysicsJointData {
  22328. /**
  22329. * Max distance the 2 joint objects can be apart
  22330. */
  22331. maxDistance: number;
  22332. }
  22333. /**
  22334. * Joint data from a spring joint
  22335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22336. */
  22337. export interface SpringJointData extends PhysicsJointData {
  22338. /**
  22339. * Length of the spring
  22340. */
  22341. length: number;
  22342. /**
  22343. * Stiffness of the spring
  22344. */
  22345. stiffness: number;
  22346. /**
  22347. * Damping of the spring
  22348. */
  22349. damping: number;
  22350. /** this callback will be called when applying the force to the impostors. */
  22351. forceApplicationCallback: () => void;
  22352. }
  22353. }
  22354. declare module BABYLON {
  22355. /**
  22356. * Holds the data for the raycast result
  22357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22358. */
  22359. export class PhysicsRaycastResult {
  22360. private _hasHit;
  22361. private _hitDistance;
  22362. private _hitNormalWorld;
  22363. private _hitPointWorld;
  22364. private _rayFromWorld;
  22365. private _rayToWorld;
  22366. /**
  22367. * Gets if there was a hit
  22368. */
  22369. readonly hasHit: boolean;
  22370. /**
  22371. * Gets the distance from the hit
  22372. */
  22373. readonly hitDistance: number;
  22374. /**
  22375. * Gets the hit normal/direction in the world
  22376. */
  22377. readonly hitNormalWorld: Vector3;
  22378. /**
  22379. * Gets the hit point in the world
  22380. */
  22381. readonly hitPointWorld: Vector3;
  22382. /**
  22383. * Gets the ray "start point" of the ray in the world
  22384. */
  22385. readonly rayFromWorld: Vector3;
  22386. /**
  22387. * Gets the ray "end point" of the ray in the world
  22388. */
  22389. readonly rayToWorld: Vector3;
  22390. /**
  22391. * Sets the hit data (normal & point in world space)
  22392. * @param hitNormalWorld defines the normal in world space
  22393. * @param hitPointWorld defines the point in world space
  22394. */
  22395. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22396. /**
  22397. * Sets the distance from the start point to the hit point
  22398. * @param distance
  22399. */
  22400. setHitDistance(distance: number): void;
  22401. /**
  22402. * Calculates the distance manually
  22403. */
  22404. calculateHitDistance(): void;
  22405. /**
  22406. * Resets all the values to default
  22407. * @param from The from point on world space
  22408. * @param to The to point on world space
  22409. */
  22410. reset(from?: Vector3, to?: Vector3): void;
  22411. }
  22412. /**
  22413. * Interface for the size containing width and height
  22414. */
  22415. interface IXYZ {
  22416. /**
  22417. * X
  22418. */
  22419. x: number;
  22420. /**
  22421. * Y
  22422. */
  22423. y: number;
  22424. /**
  22425. * Z
  22426. */
  22427. z: number;
  22428. }
  22429. }
  22430. declare module BABYLON {
  22431. /**
  22432. * Interface used to describe a physics joint
  22433. */
  22434. export interface PhysicsImpostorJoint {
  22435. /** Defines the main impostor to which the joint is linked */
  22436. mainImpostor: PhysicsImpostor;
  22437. /** Defines the impostor that is connected to the main impostor using this joint */
  22438. connectedImpostor: PhysicsImpostor;
  22439. /** Defines the joint itself */
  22440. joint: PhysicsJoint;
  22441. }
  22442. /** @hidden */
  22443. export interface IPhysicsEnginePlugin {
  22444. world: any;
  22445. name: string;
  22446. setGravity(gravity: Vector3): void;
  22447. setTimeStep(timeStep: number): void;
  22448. getTimeStep(): number;
  22449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22451. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22453. removePhysicsBody(impostor: PhysicsImpostor): void;
  22454. generateJoint(joint: PhysicsImpostorJoint): void;
  22455. removeJoint(joint: PhysicsImpostorJoint): void;
  22456. isSupported(): boolean;
  22457. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22458. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22459. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22460. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22461. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22462. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22463. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22464. getBodyMass(impostor: PhysicsImpostor): number;
  22465. getBodyFriction(impostor: PhysicsImpostor): number;
  22466. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22467. getBodyRestitution(impostor: PhysicsImpostor): number;
  22468. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22469. getBodyPressure?(impostor: PhysicsImpostor): number;
  22470. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22471. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22472. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22473. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22474. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22475. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22476. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22477. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22478. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22479. sleepBody(impostor: PhysicsImpostor): void;
  22480. wakeUpBody(impostor: PhysicsImpostor): void;
  22481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22482. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22483. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22484. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22485. getRadius(impostor: PhysicsImpostor): number;
  22486. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22487. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22488. dispose(): void;
  22489. }
  22490. /**
  22491. * Interface used to define a physics engine
  22492. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22493. */
  22494. export interface IPhysicsEngine {
  22495. /**
  22496. * Gets the gravity vector used by the simulation
  22497. */
  22498. gravity: Vector3;
  22499. /**
  22500. * Sets the gravity vector used by the simulation
  22501. * @param gravity defines the gravity vector to use
  22502. */
  22503. setGravity(gravity: Vector3): void;
  22504. /**
  22505. * Set the time step of the physics engine.
  22506. * Default is 1/60.
  22507. * To slow it down, enter 1/600 for example.
  22508. * To speed it up, 1/30
  22509. * @param newTimeStep the new timestep to apply to this world.
  22510. */
  22511. setTimeStep(newTimeStep: number): void;
  22512. /**
  22513. * Get the time step of the physics engine.
  22514. * @returns the current time step
  22515. */
  22516. getTimeStep(): number;
  22517. /**
  22518. * Release all resources
  22519. */
  22520. dispose(): void;
  22521. /**
  22522. * Gets the name of the current physics plugin
  22523. * @returns the name of the plugin
  22524. */
  22525. getPhysicsPluginName(): string;
  22526. /**
  22527. * Adding a new impostor for the impostor tracking.
  22528. * This will be done by the impostor itself.
  22529. * @param impostor the impostor to add
  22530. */
  22531. addImpostor(impostor: PhysicsImpostor): void;
  22532. /**
  22533. * Remove an impostor from the engine.
  22534. * This impostor and its mesh will not longer be updated by the physics engine.
  22535. * @param impostor the impostor to remove
  22536. */
  22537. removeImpostor(impostor: PhysicsImpostor): void;
  22538. /**
  22539. * Add a joint to the physics engine
  22540. * @param mainImpostor defines the main impostor to which the joint is added.
  22541. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22542. * @param joint defines the joint that will connect both impostors.
  22543. */
  22544. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22545. /**
  22546. * Removes a joint from the simulation
  22547. * @param mainImpostor defines the impostor used with the joint
  22548. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22549. * @param joint defines the joint to remove
  22550. */
  22551. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22552. /**
  22553. * Gets the current plugin used to run the simulation
  22554. * @returns current plugin
  22555. */
  22556. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22557. /**
  22558. * Gets the list of physic impostors
  22559. * @returns an array of PhysicsImpostor
  22560. */
  22561. getImpostors(): Array<PhysicsImpostor>;
  22562. /**
  22563. * Gets the impostor for a physics enabled object
  22564. * @param object defines the object impersonated by the impostor
  22565. * @returns the PhysicsImpostor or null if not found
  22566. */
  22567. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22568. /**
  22569. * Gets the impostor for a physics body object
  22570. * @param body defines physics body used by the impostor
  22571. * @returns the PhysicsImpostor or null if not found
  22572. */
  22573. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22574. /**
  22575. * Does a raycast in the physics world
  22576. * @param from when should the ray start?
  22577. * @param to when should the ray end?
  22578. * @returns PhysicsRaycastResult
  22579. */
  22580. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22581. /**
  22582. * Called by the scene. No need to call it.
  22583. * @param delta defines the timespam between frames
  22584. */
  22585. _step(delta: number): void;
  22586. }
  22587. }
  22588. declare module BABYLON {
  22589. /**
  22590. * The interface for the physics imposter parameters
  22591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22592. */
  22593. export interface PhysicsImpostorParameters {
  22594. /**
  22595. * The mass of the physics imposter
  22596. */
  22597. mass: number;
  22598. /**
  22599. * The friction of the physics imposter
  22600. */
  22601. friction?: number;
  22602. /**
  22603. * The coefficient of restitution of the physics imposter
  22604. */
  22605. restitution?: number;
  22606. /**
  22607. * The native options of the physics imposter
  22608. */
  22609. nativeOptions?: any;
  22610. /**
  22611. * Specifies if the parent should be ignored
  22612. */
  22613. ignoreParent?: boolean;
  22614. /**
  22615. * Specifies if bi-directional transformations should be disabled
  22616. */
  22617. disableBidirectionalTransformation?: boolean;
  22618. /**
  22619. * The pressure inside the physics imposter, soft object only
  22620. */
  22621. pressure?: number;
  22622. /**
  22623. * The stiffness the physics imposter, soft object only
  22624. */
  22625. stiffness?: number;
  22626. /**
  22627. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22628. */
  22629. velocityIterations?: number;
  22630. /**
  22631. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22632. */
  22633. positionIterations?: number;
  22634. /**
  22635. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22636. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22637. * Add to fix multiple points
  22638. */
  22639. fixedPoints?: number;
  22640. /**
  22641. * The collision margin around a soft object
  22642. */
  22643. margin?: number;
  22644. /**
  22645. * The collision margin around a soft object
  22646. */
  22647. damping?: number;
  22648. /**
  22649. * The path for a rope based on an extrusion
  22650. */
  22651. path?: any;
  22652. /**
  22653. * The shape of an extrusion used for a rope based on an extrusion
  22654. */
  22655. shape?: any;
  22656. }
  22657. /**
  22658. * Interface for a physics-enabled object
  22659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22660. */
  22661. export interface IPhysicsEnabledObject {
  22662. /**
  22663. * The position of the physics-enabled object
  22664. */
  22665. position: Vector3;
  22666. /**
  22667. * The rotation of the physics-enabled object
  22668. */
  22669. rotationQuaternion: Nullable<Quaternion>;
  22670. /**
  22671. * The scale of the physics-enabled object
  22672. */
  22673. scaling: Vector3;
  22674. /**
  22675. * The rotation of the physics-enabled object
  22676. */
  22677. rotation?: Vector3;
  22678. /**
  22679. * The parent of the physics-enabled object
  22680. */
  22681. parent?: any;
  22682. /**
  22683. * The bounding info of the physics-enabled object
  22684. * @returns The bounding info of the physics-enabled object
  22685. */
  22686. getBoundingInfo(): BoundingInfo;
  22687. /**
  22688. * Computes the world matrix
  22689. * @param force Specifies if the world matrix should be computed by force
  22690. * @returns A world matrix
  22691. */
  22692. computeWorldMatrix(force: boolean): Matrix;
  22693. /**
  22694. * Gets the world matrix
  22695. * @returns A world matrix
  22696. */
  22697. getWorldMatrix?(): Matrix;
  22698. /**
  22699. * Gets the child meshes
  22700. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22701. * @returns An array of abstract meshes
  22702. */
  22703. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22704. /**
  22705. * Gets the vertex data
  22706. * @param kind The type of vertex data
  22707. * @returns A nullable array of numbers, or a float32 array
  22708. */
  22709. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22710. /**
  22711. * Gets the indices from the mesh
  22712. * @returns A nullable array of index arrays
  22713. */
  22714. getIndices?(): Nullable<IndicesArray>;
  22715. /**
  22716. * Gets the scene from the mesh
  22717. * @returns the indices array or null
  22718. */
  22719. getScene?(): Scene;
  22720. /**
  22721. * Gets the absolute position from the mesh
  22722. * @returns the absolute position
  22723. */
  22724. getAbsolutePosition(): Vector3;
  22725. /**
  22726. * Gets the absolute pivot point from the mesh
  22727. * @returns the absolute pivot point
  22728. */
  22729. getAbsolutePivotPoint(): Vector3;
  22730. /**
  22731. * Rotates the mesh
  22732. * @param axis The axis of rotation
  22733. * @param amount The amount of rotation
  22734. * @param space The space of the rotation
  22735. * @returns The rotation transform node
  22736. */
  22737. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22738. /**
  22739. * Translates the mesh
  22740. * @param axis The axis of translation
  22741. * @param distance The distance of translation
  22742. * @param space The space of the translation
  22743. * @returns The transform node
  22744. */
  22745. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22746. /**
  22747. * Sets the absolute position of the mesh
  22748. * @param absolutePosition The absolute position of the mesh
  22749. * @returns The transform node
  22750. */
  22751. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22752. /**
  22753. * Gets the class name of the mesh
  22754. * @returns The class name
  22755. */
  22756. getClassName(): string;
  22757. }
  22758. /**
  22759. * Represents a physics imposter
  22760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22761. */
  22762. export class PhysicsImpostor {
  22763. /**
  22764. * The physics-enabled object used as the physics imposter
  22765. */
  22766. object: IPhysicsEnabledObject;
  22767. /**
  22768. * The type of the physics imposter
  22769. */
  22770. type: number;
  22771. private _options;
  22772. private _scene?;
  22773. /**
  22774. * The default object size of the imposter
  22775. */
  22776. static DEFAULT_OBJECT_SIZE: Vector3;
  22777. /**
  22778. * The identity quaternion of the imposter
  22779. */
  22780. static IDENTITY_QUATERNION: Quaternion;
  22781. /** @hidden */
  22782. _pluginData: any;
  22783. private _physicsEngine;
  22784. private _physicsBody;
  22785. private _bodyUpdateRequired;
  22786. private _onBeforePhysicsStepCallbacks;
  22787. private _onAfterPhysicsStepCallbacks;
  22788. /** @hidden */
  22789. _onPhysicsCollideCallbacks: Array<{
  22790. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22791. otherImpostors: Array<PhysicsImpostor>;
  22792. }>;
  22793. private _deltaPosition;
  22794. private _deltaRotation;
  22795. private _deltaRotationConjugated;
  22796. /** @hidden */
  22797. _isFromLine: boolean;
  22798. private _parent;
  22799. private _isDisposed;
  22800. private static _tmpVecs;
  22801. private static _tmpQuat;
  22802. /**
  22803. * Specifies if the physics imposter is disposed
  22804. */
  22805. readonly isDisposed: boolean;
  22806. /**
  22807. * Gets the mass of the physics imposter
  22808. */
  22809. mass: number;
  22810. /**
  22811. * Gets the coefficient of friction
  22812. */
  22813. /**
  22814. * Sets the coefficient of friction
  22815. */
  22816. friction: number;
  22817. /**
  22818. * Gets the coefficient of restitution
  22819. */
  22820. /**
  22821. * Sets the coefficient of restitution
  22822. */
  22823. restitution: number;
  22824. /**
  22825. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22826. */
  22827. /**
  22828. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22829. */
  22830. pressure: number;
  22831. /**
  22832. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22833. */
  22834. /**
  22835. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22836. */
  22837. stiffness: number;
  22838. /**
  22839. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22840. */
  22841. /**
  22842. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22843. */
  22844. velocityIterations: number;
  22845. /**
  22846. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22847. */
  22848. /**
  22849. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22850. */
  22851. positionIterations: number;
  22852. /**
  22853. * The unique id of the physics imposter
  22854. * set by the physics engine when adding this impostor to the array
  22855. */
  22856. uniqueId: number;
  22857. /**
  22858. * @hidden
  22859. */
  22860. soft: boolean;
  22861. /**
  22862. * @hidden
  22863. */
  22864. segments: number;
  22865. private _joints;
  22866. /**
  22867. * Initializes the physics imposter
  22868. * @param object The physics-enabled object used as the physics imposter
  22869. * @param type The type of the physics imposter
  22870. * @param _options The options for the physics imposter
  22871. * @param _scene The Babylon scene
  22872. */
  22873. constructor(
  22874. /**
  22875. * The physics-enabled object used as the physics imposter
  22876. */
  22877. object: IPhysicsEnabledObject,
  22878. /**
  22879. * The type of the physics imposter
  22880. */
  22881. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22882. /**
  22883. * This function will completly initialize this impostor.
  22884. * It will create a new body - but only if this mesh has no parent.
  22885. * If it has, this impostor will not be used other than to define the impostor
  22886. * of the child mesh.
  22887. * @hidden
  22888. */
  22889. _init(): void;
  22890. private _getPhysicsParent;
  22891. /**
  22892. * Should a new body be generated.
  22893. * @returns boolean specifying if body initialization is required
  22894. */
  22895. isBodyInitRequired(): boolean;
  22896. /**
  22897. * Sets the updated scaling
  22898. * @param updated Specifies if the scaling is updated
  22899. */
  22900. setScalingUpdated(): void;
  22901. /**
  22902. * Force a regeneration of this or the parent's impostor's body.
  22903. * Use under cautious - This will remove all joints already implemented.
  22904. */
  22905. forceUpdate(): void;
  22906. /**
  22907. * Gets the body that holds this impostor. Either its own, or its parent.
  22908. */
  22909. /**
  22910. * Set the physics body. Used mainly by the physics engine/plugin
  22911. */
  22912. physicsBody: any;
  22913. /**
  22914. * Get the parent of the physics imposter
  22915. * @returns Physics imposter or null
  22916. */
  22917. /**
  22918. * Sets the parent of the physics imposter
  22919. */
  22920. parent: Nullable<PhysicsImpostor>;
  22921. /**
  22922. * Resets the update flags
  22923. */
  22924. resetUpdateFlags(): void;
  22925. /**
  22926. * Gets the object extend size
  22927. * @returns the object extend size
  22928. */
  22929. getObjectExtendSize(): Vector3;
  22930. /**
  22931. * Gets the object center
  22932. * @returns The object center
  22933. */
  22934. getObjectCenter(): Vector3;
  22935. /**
  22936. * Get a specific parametes from the options parameter
  22937. * @param paramName The object parameter name
  22938. * @returns The object parameter
  22939. */
  22940. getParam(paramName: string): any;
  22941. /**
  22942. * Sets a specific parameter in the options given to the physics plugin
  22943. * @param paramName The parameter name
  22944. * @param value The value of the parameter
  22945. */
  22946. setParam(paramName: string, value: number): void;
  22947. /**
  22948. * Specifically change the body's mass option. Won't recreate the physics body object
  22949. * @param mass The mass of the physics imposter
  22950. */
  22951. setMass(mass: number): void;
  22952. /**
  22953. * Gets the linear velocity
  22954. * @returns linear velocity or null
  22955. */
  22956. getLinearVelocity(): Nullable<Vector3>;
  22957. /**
  22958. * Sets the linear velocity
  22959. * @param velocity linear velocity or null
  22960. */
  22961. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22962. /**
  22963. * Gets the angular velocity
  22964. * @returns angular velocity or null
  22965. */
  22966. getAngularVelocity(): Nullable<Vector3>;
  22967. /**
  22968. * Sets the angular velocity
  22969. * @param velocity The velocity or null
  22970. */
  22971. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22972. /**
  22973. * Execute a function with the physics plugin native code
  22974. * Provide a function the will have two variables - the world object and the physics body object
  22975. * @param func The function to execute with the physics plugin native code
  22976. */
  22977. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22978. /**
  22979. * Register a function that will be executed before the physics world is stepping forward
  22980. * @param func The function to execute before the physics world is stepped forward
  22981. */
  22982. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22983. /**
  22984. * Unregister a function that will be executed before the physics world is stepping forward
  22985. * @param func The function to execute before the physics world is stepped forward
  22986. */
  22987. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22988. /**
  22989. * Register a function that will be executed after the physics step
  22990. * @param func The function to execute after physics step
  22991. */
  22992. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22993. /**
  22994. * Unregisters a function that will be executed after the physics step
  22995. * @param func The function to execute after physics step
  22996. */
  22997. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22998. /**
  22999. * register a function that will be executed when this impostor collides against a different body
  23000. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23001. * @param func Callback that is executed on collision
  23002. */
  23003. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23004. /**
  23005. * Unregisters the physics imposter on contact
  23006. * @param collideAgainst The physics object to collide against
  23007. * @param func Callback to execute on collision
  23008. */
  23009. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23010. private _tmpQuat;
  23011. private _tmpQuat2;
  23012. /**
  23013. * Get the parent rotation
  23014. * @returns The parent rotation
  23015. */
  23016. getParentsRotation(): Quaternion;
  23017. /**
  23018. * this function is executed by the physics engine.
  23019. */
  23020. beforeStep: () => void;
  23021. /**
  23022. * this function is executed by the physics engine
  23023. */
  23024. afterStep: () => void;
  23025. /**
  23026. * Legacy collision detection event support
  23027. */
  23028. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23029. /**
  23030. * event and body object due to cannon's event-based architecture.
  23031. */
  23032. onCollide: (e: {
  23033. body: any;
  23034. }) => void;
  23035. /**
  23036. * Apply a force
  23037. * @param force The force to apply
  23038. * @param contactPoint The contact point for the force
  23039. * @returns The physics imposter
  23040. */
  23041. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23042. /**
  23043. * Apply an impulse
  23044. * @param force The impulse force
  23045. * @param contactPoint The contact point for the impulse force
  23046. * @returns The physics imposter
  23047. */
  23048. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23049. /**
  23050. * A help function to create a joint
  23051. * @param otherImpostor A physics imposter used to create a joint
  23052. * @param jointType The type of joint
  23053. * @param jointData The data for the joint
  23054. * @returns The physics imposter
  23055. */
  23056. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23057. /**
  23058. * Add a joint to this impostor with a different impostor
  23059. * @param otherImpostor A physics imposter used to add a joint
  23060. * @param joint The joint to add
  23061. * @returns The physics imposter
  23062. */
  23063. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23064. /**
  23065. * Add an anchor to a cloth impostor
  23066. * @param otherImpostor rigid impostor to anchor to
  23067. * @param width ratio across width from 0 to 1
  23068. * @param height ratio up height from 0 to 1
  23069. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23070. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23071. * @returns impostor the soft imposter
  23072. */
  23073. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23074. /**
  23075. * Add a hook to a rope impostor
  23076. * @param otherImpostor rigid impostor to anchor to
  23077. * @param length ratio across rope from 0 to 1
  23078. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23079. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23080. * @returns impostor the rope imposter
  23081. */
  23082. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23083. /**
  23084. * Will keep this body still, in a sleep mode.
  23085. * @returns the physics imposter
  23086. */
  23087. sleep(): PhysicsImpostor;
  23088. /**
  23089. * Wake the body up.
  23090. * @returns The physics imposter
  23091. */
  23092. wakeUp(): PhysicsImpostor;
  23093. /**
  23094. * Clones the physics imposter
  23095. * @param newObject The physics imposter clones to this physics-enabled object
  23096. * @returns A nullable physics imposter
  23097. */
  23098. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23099. /**
  23100. * Disposes the physics imposter
  23101. */
  23102. dispose(): void;
  23103. /**
  23104. * Sets the delta position
  23105. * @param position The delta position amount
  23106. */
  23107. setDeltaPosition(position: Vector3): void;
  23108. /**
  23109. * Sets the delta rotation
  23110. * @param rotation The delta rotation amount
  23111. */
  23112. setDeltaRotation(rotation: Quaternion): void;
  23113. /**
  23114. * Gets the box size of the physics imposter and stores the result in the input parameter
  23115. * @param result Stores the box size
  23116. * @returns The physics imposter
  23117. */
  23118. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23119. /**
  23120. * Gets the radius of the physics imposter
  23121. * @returns Radius of the physics imposter
  23122. */
  23123. getRadius(): number;
  23124. /**
  23125. * Sync a bone with this impostor
  23126. * @param bone The bone to sync to the impostor.
  23127. * @param boneMesh The mesh that the bone is influencing.
  23128. * @param jointPivot The pivot of the joint / bone in local space.
  23129. * @param distToJoint Optional distance from the impostor to the joint.
  23130. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23131. */
  23132. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23133. /**
  23134. * Sync impostor to a bone
  23135. * @param bone The bone that the impostor will be synced to.
  23136. * @param boneMesh The mesh that the bone is influencing.
  23137. * @param jointPivot The pivot of the joint / bone in local space.
  23138. * @param distToJoint Optional distance from the impostor to the joint.
  23139. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23140. * @param boneAxis Optional vector3 axis the bone is aligned with
  23141. */
  23142. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23143. /**
  23144. * No-Imposter type
  23145. */
  23146. static NoImpostor: number;
  23147. /**
  23148. * Sphere-Imposter type
  23149. */
  23150. static SphereImpostor: number;
  23151. /**
  23152. * Box-Imposter type
  23153. */
  23154. static BoxImpostor: number;
  23155. /**
  23156. * Plane-Imposter type
  23157. */
  23158. static PlaneImpostor: number;
  23159. /**
  23160. * Mesh-imposter type
  23161. */
  23162. static MeshImpostor: number;
  23163. /**
  23164. * Capsule-Impostor type (Ammo.js plugin only)
  23165. */
  23166. static CapsuleImpostor: number;
  23167. /**
  23168. * Cylinder-Imposter type
  23169. */
  23170. static CylinderImpostor: number;
  23171. /**
  23172. * Particle-Imposter type
  23173. */
  23174. static ParticleImpostor: number;
  23175. /**
  23176. * Heightmap-Imposter type
  23177. */
  23178. static HeightmapImpostor: number;
  23179. /**
  23180. * ConvexHull-Impostor type (Ammo.js plugin only)
  23181. */
  23182. static ConvexHullImpostor: number;
  23183. /**
  23184. * Rope-Imposter type
  23185. */
  23186. static RopeImpostor: number;
  23187. /**
  23188. * Cloth-Imposter type
  23189. */
  23190. static ClothImpostor: number;
  23191. /**
  23192. * Softbody-Imposter type
  23193. */
  23194. static SoftbodyImpostor: number;
  23195. }
  23196. }
  23197. declare module BABYLON {
  23198. /**
  23199. * @hidden
  23200. **/
  23201. export class _CreationDataStorage {
  23202. closePath?: boolean;
  23203. closeArray?: boolean;
  23204. idx: number[];
  23205. dashSize: number;
  23206. gapSize: number;
  23207. path3D: Path3D;
  23208. pathArray: Vector3[][];
  23209. arc: number;
  23210. radius: number;
  23211. cap: number;
  23212. tessellation: number;
  23213. }
  23214. /**
  23215. * @hidden
  23216. **/
  23217. class _InstanceDataStorage {
  23218. visibleInstances: any;
  23219. batchCache: _InstancesBatch;
  23220. instancesBufferSize: number;
  23221. instancesBuffer: Nullable<Buffer>;
  23222. instancesData: Float32Array;
  23223. overridenInstanceCount: number;
  23224. isFrozen: boolean;
  23225. previousBatch: Nullable<_InstancesBatch>;
  23226. hardwareInstancedRendering: boolean;
  23227. sideOrientation: number;
  23228. }
  23229. /**
  23230. * @hidden
  23231. **/
  23232. export class _InstancesBatch {
  23233. mustReturn: boolean;
  23234. visibleInstances: Nullable<InstancedMesh[]>[];
  23235. renderSelf: boolean[];
  23236. hardwareInstancedRendering: boolean[];
  23237. }
  23238. /**
  23239. * Class used to represent renderable models
  23240. */
  23241. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23242. /**
  23243. * Mesh side orientation : usually the external or front surface
  23244. */
  23245. static readonly FRONTSIDE: number;
  23246. /**
  23247. * Mesh side orientation : usually the internal or back surface
  23248. */
  23249. static readonly BACKSIDE: number;
  23250. /**
  23251. * Mesh side orientation : both internal and external or front and back surfaces
  23252. */
  23253. static readonly DOUBLESIDE: number;
  23254. /**
  23255. * Mesh side orientation : by default, `FRONTSIDE`
  23256. */
  23257. static readonly DEFAULTSIDE: number;
  23258. /**
  23259. * Mesh cap setting : no cap
  23260. */
  23261. static readonly NO_CAP: number;
  23262. /**
  23263. * Mesh cap setting : one cap at the beginning of the mesh
  23264. */
  23265. static readonly CAP_START: number;
  23266. /**
  23267. * Mesh cap setting : one cap at the end of the mesh
  23268. */
  23269. static readonly CAP_END: number;
  23270. /**
  23271. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23272. */
  23273. static readonly CAP_ALL: number;
  23274. /**
  23275. * Mesh pattern setting : no flip or rotate
  23276. */
  23277. static readonly NO_FLIP: number;
  23278. /**
  23279. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23280. */
  23281. static readonly FLIP_TILE: number;
  23282. /**
  23283. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23284. */
  23285. static readonly ROTATE_TILE: number;
  23286. /**
  23287. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23288. */
  23289. static readonly FLIP_ROW: number;
  23290. /**
  23291. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23292. */
  23293. static readonly ROTATE_ROW: number;
  23294. /**
  23295. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23296. */
  23297. static readonly FLIP_N_ROTATE_TILE: number;
  23298. /**
  23299. * Mesh pattern setting : rotate pattern and rotate
  23300. */
  23301. static readonly FLIP_N_ROTATE_ROW: number;
  23302. /**
  23303. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23304. */
  23305. static readonly CENTER: number;
  23306. /**
  23307. * Mesh tile positioning : part tiles on left
  23308. */
  23309. static readonly LEFT: number;
  23310. /**
  23311. * Mesh tile positioning : part tiles on right
  23312. */
  23313. static readonly RIGHT: number;
  23314. /**
  23315. * Mesh tile positioning : part tiles on top
  23316. */
  23317. static readonly TOP: number;
  23318. /**
  23319. * Mesh tile positioning : part tiles on bottom
  23320. */
  23321. static readonly BOTTOM: number;
  23322. /**
  23323. * Gets the default side orientation.
  23324. * @param orientation the orientation to value to attempt to get
  23325. * @returns the default orientation
  23326. * @hidden
  23327. */
  23328. static _GetDefaultSideOrientation(orientation?: number): number;
  23329. private _internalMeshDataInfo;
  23330. /**
  23331. * An event triggered before rendering the mesh
  23332. */
  23333. readonly onBeforeRenderObservable: Observable<Mesh>;
  23334. /**
  23335. * An event triggered before binding the mesh
  23336. */
  23337. readonly onBeforeBindObservable: Observable<Mesh>;
  23338. /**
  23339. * An event triggered after rendering the mesh
  23340. */
  23341. readonly onAfterRenderObservable: Observable<Mesh>;
  23342. /**
  23343. * An event triggered before drawing the mesh
  23344. */
  23345. readonly onBeforeDrawObservable: Observable<Mesh>;
  23346. private _onBeforeDrawObserver;
  23347. /**
  23348. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23349. */
  23350. onBeforeDraw: () => void;
  23351. /**
  23352. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23353. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23354. */
  23355. delayLoadState: number;
  23356. /**
  23357. * Gets the list of instances created from this mesh
  23358. * it is not supposed to be modified manually.
  23359. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23361. */
  23362. instances: InstancedMesh[];
  23363. /**
  23364. * Gets the file containing delay loading data for this mesh
  23365. */
  23366. delayLoadingFile: string;
  23367. /** @hidden */
  23368. _binaryInfo: any;
  23369. /**
  23370. * User defined function used to change how LOD level selection is done
  23371. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23372. */
  23373. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23374. /**
  23375. * Gets or sets the morph target manager
  23376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23377. */
  23378. morphTargetManager: Nullable<MorphTargetManager>;
  23379. /** @hidden */
  23380. _creationDataStorage: Nullable<_CreationDataStorage>;
  23381. /** @hidden */
  23382. _geometry: Nullable<Geometry>;
  23383. /** @hidden */
  23384. _delayInfo: Array<string>;
  23385. /** @hidden */
  23386. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23387. /** @hidden */
  23388. _instanceDataStorage: _InstanceDataStorage;
  23389. private _effectiveMaterial;
  23390. /** @hidden */
  23391. _shouldGenerateFlatShading: boolean;
  23392. /** @hidden */
  23393. _originalBuilderSideOrientation: number;
  23394. /**
  23395. * Use this property to change the original side orientation defined at construction time
  23396. */
  23397. overrideMaterialSideOrientation: Nullable<number>;
  23398. /**
  23399. * Gets the source mesh (the one used to clone this one from)
  23400. */
  23401. readonly source: Nullable<Mesh>;
  23402. /**
  23403. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23404. */
  23405. isUnIndexed: boolean;
  23406. /**
  23407. * @constructor
  23408. * @param name The value used by scene.getMeshByName() to do a lookup.
  23409. * @param scene The scene to add this mesh to.
  23410. * @param parent The parent of this mesh, if it has one
  23411. * @param source An optional Mesh from which geometry is shared, cloned.
  23412. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23413. * When false, achieved by calling a clone(), also passing False.
  23414. * This will make creation of children, recursive.
  23415. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23416. */
  23417. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23418. /**
  23419. * Gets the class name
  23420. * @returns the string "Mesh".
  23421. */
  23422. getClassName(): string;
  23423. /** @hidden */
  23424. readonly _isMesh: boolean;
  23425. /**
  23426. * Returns a description of this mesh
  23427. * @param fullDetails define if full details about this mesh must be used
  23428. * @returns a descriptive string representing this mesh
  23429. */
  23430. toString(fullDetails?: boolean): string;
  23431. /** @hidden */
  23432. _unBindEffect(): void;
  23433. /**
  23434. * Gets a boolean indicating if this mesh has LOD
  23435. */
  23436. readonly hasLODLevels: boolean;
  23437. /**
  23438. * Gets the list of MeshLODLevel associated with the current mesh
  23439. * @returns an array of MeshLODLevel
  23440. */
  23441. getLODLevels(): MeshLODLevel[];
  23442. private _sortLODLevels;
  23443. /**
  23444. * Add a mesh as LOD level triggered at the given distance.
  23445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23446. * @param distance The distance from the center of the object to show this level
  23447. * @param mesh The mesh to be added as LOD level (can be null)
  23448. * @return This mesh (for chaining)
  23449. */
  23450. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23451. /**
  23452. * Returns the LOD level mesh at the passed distance or null if not found.
  23453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23454. * @param distance The distance from the center of the object to show this level
  23455. * @returns a Mesh or `null`
  23456. */
  23457. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23458. /**
  23459. * Remove a mesh from the LOD array
  23460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23461. * @param mesh defines the mesh to be removed
  23462. * @return This mesh (for chaining)
  23463. */
  23464. removeLODLevel(mesh: Mesh): Mesh;
  23465. /**
  23466. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23467. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23468. * @param camera defines the camera to use to compute distance
  23469. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23470. * @return This mesh (for chaining)
  23471. */
  23472. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23473. /**
  23474. * Gets the mesh internal Geometry object
  23475. */
  23476. readonly geometry: Nullable<Geometry>;
  23477. /**
  23478. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23479. * @returns the total number of vertices
  23480. */
  23481. getTotalVertices(): number;
  23482. /**
  23483. * Returns the content of an associated vertex buffer
  23484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23485. * - VertexBuffer.PositionKind
  23486. * - VertexBuffer.UVKind
  23487. * - VertexBuffer.UV2Kind
  23488. * - VertexBuffer.UV3Kind
  23489. * - VertexBuffer.UV4Kind
  23490. * - VertexBuffer.UV5Kind
  23491. * - VertexBuffer.UV6Kind
  23492. * - VertexBuffer.ColorKind
  23493. * - VertexBuffer.MatricesIndicesKind
  23494. * - VertexBuffer.MatricesIndicesExtraKind
  23495. * - VertexBuffer.MatricesWeightsKind
  23496. * - VertexBuffer.MatricesWeightsExtraKind
  23497. * @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
  23498. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23499. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23500. */
  23501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23502. /**
  23503. * Returns the mesh VertexBuffer object from the requested `kind`
  23504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23505. * - VertexBuffer.PositionKind
  23506. * - VertexBuffer.NormalKind
  23507. * - VertexBuffer.UVKind
  23508. * - VertexBuffer.UV2Kind
  23509. * - VertexBuffer.UV3Kind
  23510. * - VertexBuffer.UV4Kind
  23511. * - VertexBuffer.UV5Kind
  23512. * - VertexBuffer.UV6Kind
  23513. * - VertexBuffer.ColorKind
  23514. * - VertexBuffer.MatricesIndicesKind
  23515. * - VertexBuffer.MatricesIndicesExtraKind
  23516. * - VertexBuffer.MatricesWeightsKind
  23517. * - VertexBuffer.MatricesWeightsExtraKind
  23518. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23519. */
  23520. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23521. /**
  23522. * Tests if a specific vertex buffer is associated with this mesh
  23523. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23524. * - VertexBuffer.PositionKind
  23525. * - VertexBuffer.NormalKind
  23526. * - VertexBuffer.UVKind
  23527. * - VertexBuffer.UV2Kind
  23528. * - VertexBuffer.UV3Kind
  23529. * - VertexBuffer.UV4Kind
  23530. * - VertexBuffer.UV5Kind
  23531. * - VertexBuffer.UV6Kind
  23532. * - VertexBuffer.ColorKind
  23533. * - VertexBuffer.MatricesIndicesKind
  23534. * - VertexBuffer.MatricesIndicesExtraKind
  23535. * - VertexBuffer.MatricesWeightsKind
  23536. * - VertexBuffer.MatricesWeightsExtraKind
  23537. * @returns a boolean
  23538. */
  23539. isVerticesDataPresent(kind: string): boolean;
  23540. /**
  23541. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23542. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23543. * - VertexBuffer.PositionKind
  23544. * - VertexBuffer.UVKind
  23545. * - VertexBuffer.UV2Kind
  23546. * - VertexBuffer.UV3Kind
  23547. * - VertexBuffer.UV4Kind
  23548. * - VertexBuffer.UV5Kind
  23549. * - VertexBuffer.UV6Kind
  23550. * - VertexBuffer.ColorKind
  23551. * - VertexBuffer.MatricesIndicesKind
  23552. * - VertexBuffer.MatricesIndicesExtraKind
  23553. * - VertexBuffer.MatricesWeightsKind
  23554. * - VertexBuffer.MatricesWeightsExtraKind
  23555. * @returns a boolean
  23556. */
  23557. isVertexBufferUpdatable(kind: string): boolean;
  23558. /**
  23559. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23561. * - VertexBuffer.PositionKind
  23562. * - VertexBuffer.NormalKind
  23563. * - VertexBuffer.UVKind
  23564. * - VertexBuffer.UV2Kind
  23565. * - VertexBuffer.UV3Kind
  23566. * - VertexBuffer.UV4Kind
  23567. * - VertexBuffer.UV5Kind
  23568. * - VertexBuffer.UV6Kind
  23569. * - VertexBuffer.ColorKind
  23570. * - VertexBuffer.MatricesIndicesKind
  23571. * - VertexBuffer.MatricesIndicesExtraKind
  23572. * - VertexBuffer.MatricesWeightsKind
  23573. * - VertexBuffer.MatricesWeightsExtraKind
  23574. * @returns an array of strings
  23575. */
  23576. getVerticesDataKinds(): string[];
  23577. /**
  23578. * Returns a positive integer : the total number of indices in this mesh geometry.
  23579. * @returns the numner of indices or zero if the mesh has no geometry.
  23580. */
  23581. getTotalIndices(): number;
  23582. /**
  23583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23584. * @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.
  23585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23586. * @returns the indices array or an empty array if the mesh has no geometry
  23587. */
  23588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23589. readonly isBlocked: boolean;
  23590. /**
  23591. * Determine if the current mesh is ready to be rendered
  23592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23593. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23594. * @returns true if all associated assets are ready (material, textures, shaders)
  23595. */
  23596. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23597. /**
  23598. * 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.
  23599. */
  23600. readonly areNormalsFrozen: boolean;
  23601. /**
  23602. * 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.
  23603. * @returns the current mesh
  23604. */
  23605. freezeNormals(): Mesh;
  23606. /**
  23607. * 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
  23608. * @returns the current mesh
  23609. */
  23610. unfreezeNormals(): Mesh;
  23611. /**
  23612. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23613. */
  23614. overridenInstanceCount: number;
  23615. /** @hidden */
  23616. _preActivate(): Mesh;
  23617. /** @hidden */
  23618. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23619. /** @hidden */
  23620. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23621. /**
  23622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23623. * This means the mesh underlying bounding box and sphere are recomputed.
  23624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23625. * @returns the current mesh
  23626. */
  23627. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23628. /** @hidden */
  23629. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23630. /**
  23631. * This function will subdivide the mesh into multiple submeshes
  23632. * @param count defines the expected number of submeshes
  23633. */
  23634. subdivide(count: number): void;
  23635. /**
  23636. * Copy a FloatArray into a specific associated vertex buffer
  23637. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23638. * - VertexBuffer.PositionKind
  23639. * - VertexBuffer.UVKind
  23640. * - VertexBuffer.UV2Kind
  23641. * - VertexBuffer.UV3Kind
  23642. * - VertexBuffer.UV4Kind
  23643. * - VertexBuffer.UV5Kind
  23644. * - VertexBuffer.UV6Kind
  23645. * - VertexBuffer.ColorKind
  23646. * - VertexBuffer.MatricesIndicesKind
  23647. * - VertexBuffer.MatricesIndicesExtraKind
  23648. * - VertexBuffer.MatricesWeightsKind
  23649. * - VertexBuffer.MatricesWeightsExtraKind
  23650. * @param data defines the data source
  23651. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23652. * @param stride defines the data stride size (can be null)
  23653. * @returns the current mesh
  23654. */
  23655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23656. /**
  23657. * Flags an associated vertex buffer as updatable
  23658. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23659. * - VertexBuffer.PositionKind
  23660. * - VertexBuffer.UVKind
  23661. * - VertexBuffer.UV2Kind
  23662. * - VertexBuffer.UV3Kind
  23663. * - VertexBuffer.UV4Kind
  23664. * - VertexBuffer.UV5Kind
  23665. * - VertexBuffer.UV6Kind
  23666. * - VertexBuffer.ColorKind
  23667. * - VertexBuffer.MatricesIndicesKind
  23668. * - VertexBuffer.MatricesIndicesExtraKind
  23669. * - VertexBuffer.MatricesWeightsKind
  23670. * - VertexBuffer.MatricesWeightsExtraKind
  23671. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23672. */
  23673. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23674. /**
  23675. * Sets the mesh global Vertex Buffer
  23676. * @param buffer defines the buffer to use
  23677. * @returns the current mesh
  23678. */
  23679. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23680. /**
  23681. * Update a specific associated vertex buffer
  23682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23683. * - VertexBuffer.PositionKind
  23684. * - VertexBuffer.UVKind
  23685. * - VertexBuffer.UV2Kind
  23686. * - VertexBuffer.UV3Kind
  23687. * - VertexBuffer.UV4Kind
  23688. * - VertexBuffer.UV5Kind
  23689. * - VertexBuffer.UV6Kind
  23690. * - VertexBuffer.ColorKind
  23691. * - VertexBuffer.MatricesIndicesKind
  23692. * - VertexBuffer.MatricesIndicesExtraKind
  23693. * - VertexBuffer.MatricesWeightsKind
  23694. * - VertexBuffer.MatricesWeightsExtraKind
  23695. * @param data defines the data source
  23696. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23697. * @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)
  23698. * @returns the current mesh
  23699. */
  23700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23701. /**
  23702. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23703. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23704. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23705. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23706. * @returns the current mesh
  23707. */
  23708. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23709. /**
  23710. * Creates a un-shared specific occurence of the geometry for the mesh.
  23711. * @returns the current mesh
  23712. */
  23713. makeGeometryUnique(): Mesh;
  23714. /**
  23715. * Set the index buffer of this mesh
  23716. * @param indices defines the source data
  23717. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23718. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23719. * @returns the current mesh
  23720. */
  23721. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23722. /**
  23723. * Update the current index buffer
  23724. * @param indices defines the source data
  23725. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23726. * @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)
  23727. * @returns the current mesh
  23728. */
  23729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23730. /**
  23731. * Invert the geometry to move from a right handed system to a left handed one.
  23732. * @returns the current mesh
  23733. */
  23734. toLeftHanded(): Mesh;
  23735. /** @hidden */
  23736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23737. /** @hidden */
  23738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23739. /**
  23740. * Registers for this mesh a javascript function called just before the rendering process
  23741. * @param func defines the function to call before rendering this mesh
  23742. * @returns the current mesh
  23743. */
  23744. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23745. /**
  23746. * Disposes a previously registered javascript function called before the rendering
  23747. * @param func defines the function to remove
  23748. * @returns the current mesh
  23749. */
  23750. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23751. /**
  23752. * Registers for this mesh a javascript function called just after the rendering is complete
  23753. * @param func defines the function to call after rendering this mesh
  23754. * @returns the current mesh
  23755. */
  23756. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23757. /**
  23758. * Disposes a previously registered javascript function called after the rendering.
  23759. * @param func defines the function to remove
  23760. * @returns the current mesh
  23761. */
  23762. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23763. /** @hidden */
  23764. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23765. /** @hidden */
  23766. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23767. /** @hidden */
  23768. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23769. /** @hidden */
  23770. _rebuild(): void;
  23771. /** @hidden */
  23772. _freeze(): void;
  23773. /** @hidden */
  23774. _unFreeze(): void;
  23775. /**
  23776. * 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
  23777. * @param subMesh defines the subMesh to render
  23778. * @param enableAlphaMode defines if alpha mode can be changed
  23779. * @returns the current mesh
  23780. */
  23781. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23782. private _onBeforeDraw;
  23783. /**
  23784. * Renormalize the mesh and patch it up if there are no weights
  23785. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23786. * However in the case of zero weights then we set just a single influence to 1.
  23787. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23788. */
  23789. cleanMatrixWeights(): void;
  23790. private normalizeSkinFourWeights;
  23791. private normalizeSkinWeightsAndExtra;
  23792. /**
  23793. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23794. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23795. * the user know there was an issue with importing the mesh
  23796. * @returns a validation object with skinned, valid and report string
  23797. */
  23798. validateSkinning(): {
  23799. skinned: boolean;
  23800. valid: boolean;
  23801. report: string;
  23802. };
  23803. /** @hidden */
  23804. _checkDelayState(): Mesh;
  23805. private _queueLoad;
  23806. /**
  23807. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23808. * A mesh is in the frustum if its bounding box intersects the frustum
  23809. * @param frustumPlanes defines the frustum to test
  23810. * @returns true if the mesh is in the frustum planes
  23811. */
  23812. isInFrustum(frustumPlanes: Plane[]): boolean;
  23813. /**
  23814. * Sets the mesh material by the material or multiMaterial `id` property
  23815. * @param id is a string identifying the material or the multiMaterial
  23816. * @returns the current mesh
  23817. */
  23818. setMaterialByID(id: string): Mesh;
  23819. /**
  23820. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23821. * @returns an array of IAnimatable
  23822. */
  23823. getAnimatables(): IAnimatable[];
  23824. /**
  23825. * Modifies the mesh geometry according to the passed transformation matrix.
  23826. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23827. * The mesh normals are modified using the same transformation.
  23828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23829. * @param transform defines the transform matrix to use
  23830. * @see http://doc.babylonjs.com/resources/baking_transformations
  23831. * @returns the current mesh
  23832. */
  23833. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23834. /**
  23835. * Modifies the mesh geometry according to its own current World Matrix.
  23836. * The mesh World Matrix is then reset.
  23837. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23838. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23839. * @see http://doc.babylonjs.com/resources/baking_transformations
  23840. * @returns the current mesh
  23841. */
  23842. bakeCurrentTransformIntoVertices(): Mesh;
  23843. /** @hidden */
  23844. readonly _positions: Nullable<Vector3[]>;
  23845. /** @hidden */
  23846. _resetPointsArrayCache(): Mesh;
  23847. /** @hidden */
  23848. _generatePointsArray(): boolean;
  23849. /**
  23850. * Returns a new Mesh object generated from the current mesh properties.
  23851. * This method must not get confused with createInstance()
  23852. * @param name is a string, the name given to the new mesh
  23853. * @param newParent can be any Node object (default `null`)
  23854. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23855. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23856. * @returns a new mesh
  23857. */
  23858. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23859. /**
  23860. * Releases resources associated with this mesh.
  23861. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23862. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23863. */
  23864. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23865. /**
  23866. * Modifies the mesh geometry according to a displacement map.
  23867. * 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.
  23868. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23869. * @param url is a string, the URL from the image file is to be downloaded.
  23870. * @param minHeight is the lower limit of the displacement.
  23871. * @param maxHeight is the upper limit of the displacement.
  23872. * @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.
  23873. * @param uvOffset is an optional vector2 used to offset UV.
  23874. * @param uvScale is an optional vector2 used to scale UV.
  23875. * @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.
  23876. * @returns the Mesh.
  23877. */
  23878. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23879. /**
  23880. * Modifies the mesh geometry according to a displacementMap buffer.
  23881. * 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.
  23882. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23883. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23884. * @param heightMapWidth is the width of the buffer image.
  23885. * @param heightMapHeight is the height of the buffer image.
  23886. * @param minHeight is the lower limit of the displacement.
  23887. * @param maxHeight is the upper limit of the displacement.
  23888. * @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.
  23889. * @param uvOffset is an optional vector2 used to offset UV.
  23890. * @param uvScale is an optional vector2 used to scale UV.
  23891. * @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.
  23892. * @returns the Mesh.
  23893. */
  23894. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23895. /**
  23896. * Modify the mesh to get a flat shading rendering.
  23897. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23898. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23899. * @returns current mesh
  23900. */
  23901. convertToFlatShadedMesh(): Mesh;
  23902. /**
  23903. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23904. * In other words, more vertices, no more indices and a single bigger VBO.
  23905. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23906. * @returns current mesh
  23907. */
  23908. convertToUnIndexedMesh(): Mesh;
  23909. /**
  23910. * Inverses facet orientations.
  23911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23912. * @param flipNormals will also inverts the normals
  23913. * @returns current mesh
  23914. */
  23915. flipFaces(flipNormals?: boolean): Mesh;
  23916. /**
  23917. * Increase the number of facets and hence vertices in a mesh
  23918. * Vertex normals are interpolated from existing vertex normals
  23919. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23920. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23921. */
  23922. increaseVertices(numberPerEdge: number): void;
  23923. /**
  23924. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23925. * This will undo any application of covertToFlatShadedMesh
  23926. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23927. */
  23928. forceSharedVertices(): void;
  23929. /** @hidden */
  23930. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23931. /** @hidden */
  23932. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23933. /**
  23934. * Creates a new InstancedMesh object from the mesh model.
  23935. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23936. * @param name defines the name of the new instance
  23937. * @returns a new InstancedMesh
  23938. */
  23939. createInstance(name: string): InstancedMesh;
  23940. /**
  23941. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23942. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23943. * @returns the current mesh
  23944. */
  23945. synchronizeInstances(): Mesh;
  23946. /**
  23947. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23948. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23949. * This should be used together with the simplification to avoid disappearing triangles.
  23950. * @param successCallback an optional success callback to be called after the optimization finished.
  23951. * @returns the current mesh
  23952. */
  23953. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23954. /**
  23955. * Serialize current mesh
  23956. * @param serializationObject defines the object which will receive the serialization data
  23957. */
  23958. serialize(serializationObject: any): void;
  23959. /** @hidden */
  23960. _syncGeometryWithMorphTargetManager(): void;
  23961. /** @hidden */
  23962. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23963. /**
  23964. * Returns a new Mesh object parsed from the source provided.
  23965. * @param parsedMesh is the source
  23966. * @param scene defines the hosting scene
  23967. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23968. * @returns a new Mesh
  23969. */
  23970. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23971. /**
  23972. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23973. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23974. * @param name defines the name of the mesh to create
  23975. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23976. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23977. * @param closePath creates a seam between the first and the last points of each path of the path array
  23978. * @param offset is taken in account only if the `pathArray` is containing a single path
  23979. * @param scene defines the hosting scene
  23980. * @param updatable defines if the mesh must be flagged as updatable
  23981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23982. * @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)
  23983. * @returns a new Mesh
  23984. */
  23985. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23986. /**
  23987. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23988. * @param name defines the name of the mesh to create
  23989. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23990. * @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
  23991. * @param scene defines the hosting scene
  23992. * @param updatable defines if the mesh must be flagged as updatable
  23993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23994. * @returns a new Mesh
  23995. */
  23996. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23997. /**
  23998. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23999. * @param name defines the name of the mesh to create
  24000. * @param size sets the size (float) of each box side (default 1)
  24001. * @param scene defines the hosting scene
  24002. * @param updatable defines if the mesh must be flagged as updatable
  24003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24004. * @returns a new Mesh
  24005. */
  24006. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24007. /**
  24008. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24009. * @param name defines the name of the mesh to create
  24010. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24011. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24012. * @param scene defines the hosting scene
  24013. * @param updatable defines if the mesh must be flagged as updatable
  24014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24015. * @returns a new Mesh
  24016. */
  24017. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24018. /**
  24019. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24020. * @param name defines the name of the mesh to create
  24021. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24022. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24023. * @param scene defines the hosting scene
  24024. * @returns a new Mesh
  24025. */
  24026. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24027. /**
  24028. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24029. * @param name defines the name of the mesh to create
  24030. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24031. * @param diameterTop set the top cap diameter (floats, default 1)
  24032. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24033. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24034. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24035. * @param scene defines the hosting scene
  24036. * @param updatable defines if the mesh must be flagged as updatable
  24037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24038. * @returns a new Mesh
  24039. */
  24040. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24041. /**
  24042. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24043. * @param name defines the name of the mesh to create
  24044. * @param diameter sets the diameter size (float) of the torus (default 1)
  24045. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24046. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24047. * @param scene defines the hosting scene
  24048. * @param updatable defines if the mesh must be flagged as updatable
  24049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24050. * @returns a new Mesh
  24051. */
  24052. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24053. /**
  24054. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24055. * @param name defines the name of the mesh to create
  24056. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24057. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24058. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24059. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24060. * @param p the number of windings on X axis (positive integers, default 2)
  24061. * @param q the number of windings on Y axis (positive integers, default 3)
  24062. * @param scene defines the hosting scene
  24063. * @param updatable defines if the mesh must be flagged as updatable
  24064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24065. * @returns a new Mesh
  24066. */
  24067. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24068. /**
  24069. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24070. * @param name defines the name of the mesh to create
  24071. * @param points is an array successive Vector3
  24072. * @param scene defines the hosting scene
  24073. * @param updatable defines if the mesh must be flagged as updatable
  24074. * @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).
  24075. * @returns a new Mesh
  24076. */
  24077. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24078. /**
  24079. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24080. * @param name defines the name of the mesh to create
  24081. * @param points is an array successive Vector3
  24082. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24083. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24084. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24085. * @param scene defines the hosting scene
  24086. * @param updatable defines if the mesh must be flagged as updatable
  24087. * @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)
  24088. * @returns a new Mesh
  24089. */
  24090. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24091. /**
  24092. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24094. * 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.
  24095. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24096. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24097. * Remember you can only change the shape positions, not their number when updating a polygon.
  24098. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24099. * @param name defines the name of the mesh to create
  24100. * @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
  24101. * @param scene defines the hosting scene
  24102. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24103. * @param updatable defines if the mesh must be flagged as updatable
  24104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24105. * @param earcutInjection can be used to inject your own earcut reference
  24106. * @returns a new Mesh
  24107. */
  24108. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24109. /**
  24110. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24112. * @param name defines the name of the mesh to create
  24113. * @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
  24114. * @param depth defines the height of extrusion
  24115. * @param scene defines the hosting scene
  24116. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24117. * @param updatable defines if the mesh must be flagged as updatable
  24118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24119. * @param earcutInjection can be used to inject your own earcut reference
  24120. * @returns a new Mesh
  24121. */
  24122. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24123. /**
  24124. * Creates an extruded shape mesh.
  24125. * 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
  24126. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24127. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24128. * @param name defines the name of the mesh to create
  24129. * @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
  24130. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24131. * @param scale is the value to scale the shape
  24132. * @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
  24133. * @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
  24134. * @param scene defines the hosting scene
  24135. * @param updatable defines if the mesh must be flagged as updatable
  24136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24137. * @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)
  24138. * @returns a new Mesh
  24139. */
  24140. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24141. /**
  24142. * Creates an custom extruded shape mesh.
  24143. * The custom extrusion is a parametric shape.
  24144. * It has no predefined shape. Its final shape will depend on the input parameters.
  24145. * Please consider using the same method from the MeshBuilder class instead
  24146. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24147. * @param name defines the name of the mesh to create
  24148. * @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
  24149. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24150. * @param scaleFunction is a custom Javascript function called on each path point
  24151. * @param rotationFunction is a custom Javascript function called on each path point
  24152. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24153. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24154. * @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
  24155. * @param scene defines the hosting scene
  24156. * @param updatable defines if the mesh must be flagged as updatable
  24157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24158. * @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)
  24159. * @returns a new Mesh
  24160. */
  24161. 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;
  24162. /**
  24163. * Creates lathe mesh.
  24164. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24165. * Please consider using the same method from the MeshBuilder class instead
  24166. * @param name defines the name of the mesh to create
  24167. * @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
  24168. * @param radius is the radius value of the lathe
  24169. * @param tessellation is the side number of the lathe.
  24170. * @param scene defines the hosting scene
  24171. * @param updatable defines if the mesh must be flagged as updatable
  24172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24173. * @returns a new Mesh
  24174. */
  24175. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24176. /**
  24177. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24178. * @param name defines the name of the mesh to create
  24179. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24180. * @param scene defines the hosting scene
  24181. * @param updatable defines if the mesh must be flagged as updatable
  24182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24183. * @returns a new Mesh
  24184. */
  24185. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24186. /**
  24187. * Creates a ground mesh.
  24188. * Please consider using the same method from the MeshBuilder class instead
  24189. * @param name defines the name of the mesh to create
  24190. * @param width set the width of the ground
  24191. * @param height set the height of the ground
  24192. * @param subdivisions sets the number of subdivisions per side
  24193. * @param scene defines the hosting scene
  24194. * @param updatable defines if the mesh must be flagged as updatable
  24195. * @returns a new Mesh
  24196. */
  24197. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24198. /**
  24199. * Creates a tiled ground mesh.
  24200. * Please consider using the same method from the MeshBuilder class instead
  24201. * @param name defines the name of the mesh to create
  24202. * @param xmin set the ground minimum X coordinate
  24203. * @param zmin set the ground minimum Y coordinate
  24204. * @param xmax set the ground maximum X coordinate
  24205. * @param zmax set the ground maximum Z coordinate
  24206. * @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
  24207. * @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
  24208. * @param scene defines the hosting scene
  24209. * @param updatable defines if the mesh must be flagged as updatable
  24210. * @returns a new Mesh
  24211. */
  24212. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24213. w: number;
  24214. h: number;
  24215. }, precision: {
  24216. w: number;
  24217. h: number;
  24218. }, scene: Scene, updatable?: boolean): Mesh;
  24219. /**
  24220. * Creates a ground mesh from a height map.
  24221. * Please consider using the same method from the MeshBuilder class instead
  24222. * @see http://doc.babylonjs.com/babylon101/height_map
  24223. * @param name defines the name of the mesh to create
  24224. * @param url sets the URL of the height map image resource
  24225. * @param width set the ground width size
  24226. * @param height set the ground height size
  24227. * @param subdivisions sets the number of subdivision per side
  24228. * @param minHeight is the minimum altitude on the ground
  24229. * @param maxHeight is the maximum altitude on the ground
  24230. * @param scene defines the hosting scene
  24231. * @param updatable defines if the mesh must be flagged as updatable
  24232. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24233. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24234. * @returns a new Mesh
  24235. */
  24236. 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;
  24237. /**
  24238. * Creates a tube mesh.
  24239. * The tube is a parametric shape.
  24240. * It has no predefined shape. Its final shape will depend on the input parameters.
  24241. * Please consider using the same method from the MeshBuilder class instead
  24242. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24243. * @param name defines the name of the mesh to create
  24244. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24245. * @param radius sets the tube radius size
  24246. * @param tessellation is the number of sides on the tubular surface
  24247. * @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
  24248. * @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
  24249. * @param scene defines the hosting scene
  24250. * @param updatable defines if the mesh must be flagged as updatable
  24251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24252. * @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)
  24253. * @returns a new Mesh
  24254. */
  24255. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24256. (i: number, distance: number): number;
  24257. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24258. /**
  24259. * Creates a polyhedron mesh.
  24260. * Please consider using the same method from the MeshBuilder class instead.
  24261. * * 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
  24262. * * The parameter `size` (positive float, default 1) sets the polygon size
  24263. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24264. * * 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`
  24265. * * 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
  24266. * * 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)`)
  24267. * * 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
  24268. * * 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
  24269. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24270. * * 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
  24271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24272. * @param name defines the name of the mesh to create
  24273. * @param options defines the options used to create the mesh
  24274. * @param scene defines the hosting scene
  24275. * @returns a new Mesh
  24276. */
  24277. static CreatePolyhedron(name: string, options: {
  24278. type?: number;
  24279. size?: number;
  24280. sizeX?: number;
  24281. sizeY?: number;
  24282. sizeZ?: number;
  24283. custom?: any;
  24284. faceUV?: Vector4[];
  24285. faceColors?: Color4[];
  24286. updatable?: boolean;
  24287. sideOrientation?: number;
  24288. }, scene: Scene): Mesh;
  24289. /**
  24290. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24291. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24292. * * 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`)
  24293. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24294. * * 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
  24295. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24296. * * 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
  24297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24298. * @param name defines the name of the mesh
  24299. * @param options defines the options used to create the mesh
  24300. * @param scene defines the hosting scene
  24301. * @returns a new Mesh
  24302. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24303. */
  24304. static CreateIcoSphere(name: string, options: {
  24305. radius?: number;
  24306. flat?: boolean;
  24307. subdivisions?: number;
  24308. sideOrientation?: number;
  24309. updatable?: boolean;
  24310. }, scene: Scene): Mesh;
  24311. /**
  24312. * Creates a decal mesh.
  24313. * Please consider using the same method from the MeshBuilder class instead.
  24314. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24315. * @param name defines the name of the mesh
  24316. * @param sourceMesh defines the mesh receiving the decal
  24317. * @param position sets the position of the decal in world coordinates
  24318. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24319. * @param size sets the decal scaling
  24320. * @param angle sets the angle to rotate the decal
  24321. * @returns a new Mesh
  24322. */
  24323. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24324. /**
  24325. * Prepare internal position array for software CPU skinning
  24326. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24327. */
  24328. setPositionsForCPUSkinning(): Float32Array;
  24329. /**
  24330. * Prepare internal normal array for software CPU skinning
  24331. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24332. */
  24333. setNormalsForCPUSkinning(): Float32Array;
  24334. /**
  24335. * Updates the vertex buffer by applying transformation from the bones
  24336. * @param skeleton defines the skeleton to apply to current mesh
  24337. * @returns the current mesh
  24338. */
  24339. applySkeleton(skeleton: Skeleton): Mesh;
  24340. /**
  24341. * 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
  24342. * @param meshes defines the list of meshes to scan
  24343. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24344. */
  24345. static MinMax(meshes: AbstractMesh[]): {
  24346. min: Vector3;
  24347. max: Vector3;
  24348. };
  24349. /**
  24350. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24351. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24352. * @returns a vector3
  24353. */
  24354. static Center(meshesOrMinMaxVector: {
  24355. min: Vector3;
  24356. max: Vector3;
  24357. } | AbstractMesh[]): Vector3;
  24358. /**
  24359. * Merge the array of meshes into a single mesh for performance reasons.
  24360. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24361. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24362. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24363. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24364. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24365. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24366. * @returns a new mesh
  24367. */
  24368. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24369. /** @hidden */
  24370. addInstance(instance: InstancedMesh): void;
  24371. /** @hidden */
  24372. removeInstance(instance: InstancedMesh): void;
  24373. }
  24374. }
  24375. declare module BABYLON {
  24376. /**
  24377. * This is the base class of all the camera used in the application.
  24378. * @see http://doc.babylonjs.com/features/cameras
  24379. */
  24380. export class Camera extends Node {
  24381. /** @hidden */
  24382. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24383. /**
  24384. * This is the default projection mode used by the cameras.
  24385. * It helps recreating a feeling of perspective and better appreciate depth.
  24386. * This is the best way to simulate real life cameras.
  24387. */
  24388. static readonly PERSPECTIVE_CAMERA: number;
  24389. /**
  24390. * This helps creating camera with an orthographic mode.
  24391. * 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.
  24392. */
  24393. static readonly ORTHOGRAPHIC_CAMERA: number;
  24394. /**
  24395. * This is the default FOV mode for perspective cameras.
  24396. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24397. */
  24398. static readonly FOVMODE_VERTICAL_FIXED: number;
  24399. /**
  24400. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24401. */
  24402. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24403. /**
  24404. * This specifies ther is no need for a camera rig.
  24405. * Basically only one eye is rendered corresponding to the camera.
  24406. */
  24407. static readonly RIG_MODE_NONE: number;
  24408. /**
  24409. * Simulates a camera Rig with one blue eye and one red eye.
  24410. * This can be use with 3d blue and red glasses.
  24411. */
  24412. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24413. /**
  24414. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24415. */
  24416. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24417. /**
  24418. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24419. */
  24420. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24421. /**
  24422. * Defines that both eyes of the camera will be rendered over under each other.
  24423. */
  24424. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24425. /**
  24426. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24427. */
  24428. static readonly RIG_MODE_VR: number;
  24429. /**
  24430. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24431. */
  24432. static readonly RIG_MODE_WEBVR: number;
  24433. /**
  24434. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24435. */
  24436. static readonly RIG_MODE_CUSTOM: number;
  24437. /**
  24438. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24439. */
  24440. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24441. /**
  24442. * Define the input manager associated with the camera.
  24443. */
  24444. inputs: CameraInputsManager<Camera>;
  24445. /** @hidden */
  24446. _position: Vector3;
  24447. /**
  24448. * Define the current local position of the camera in the scene
  24449. */
  24450. position: Vector3;
  24451. /**
  24452. * The vector the camera should consider as up.
  24453. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24454. */
  24455. upVector: Vector3;
  24456. /**
  24457. * Define the current limit on the left side for an orthographic camera
  24458. * In scene unit
  24459. */
  24460. orthoLeft: Nullable<number>;
  24461. /**
  24462. * Define the current limit on the right side for an orthographic camera
  24463. * In scene unit
  24464. */
  24465. orthoRight: Nullable<number>;
  24466. /**
  24467. * Define the current limit on the bottom side for an orthographic camera
  24468. * In scene unit
  24469. */
  24470. orthoBottom: Nullable<number>;
  24471. /**
  24472. * Define the current limit on the top side for an orthographic camera
  24473. * In scene unit
  24474. */
  24475. orthoTop: Nullable<number>;
  24476. /**
  24477. * Field Of View is set in Radians. (default is 0.8)
  24478. */
  24479. fov: number;
  24480. /**
  24481. * Define the minimum distance the camera can see from.
  24482. * This is important to note that the depth buffer are not infinite and the closer it starts
  24483. * the more your scene might encounter depth fighting issue.
  24484. */
  24485. minZ: number;
  24486. /**
  24487. * Define the maximum distance the camera can see to.
  24488. * This is important to note that the depth buffer are not infinite and the further it end
  24489. * the more your scene might encounter depth fighting issue.
  24490. */
  24491. maxZ: number;
  24492. /**
  24493. * Define the default inertia of the camera.
  24494. * This helps giving a smooth feeling to the camera movement.
  24495. */
  24496. inertia: number;
  24497. /**
  24498. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24499. */
  24500. mode: number;
  24501. /**
  24502. * Define wether the camera is intermediate.
  24503. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24504. */
  24505. isIntermediate: boolean;
  24506. /**
  24507. * Define the viewport of the camera.
  24508. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24509. */
  24510. viewport: Viewport;
  24511. /**
  24512. * Restricts the camera to viewing objects with the same layerMask.
  24513. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24514. */
  24515. layerMask: number;
  24516. /**
  24517. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24518. */
  24519. fovMode: number;
  24520. /**
  24521. * Rig mode of the camera.
  24522. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24523. * This is normally controlled byt the camera themselves as internal use.
  24524. */
  24525. cameraRigMode: number;
  24526. /**
  24527. * Defines the distance between both "eyes" in case of a RIG
  24528. */
  24529. interaxialDistance: number;
  24530. /**
  24531. * Defines if stereoscopic rendering is done side by side or over under.
  24532. */
  24533. isStereoscopicSideBySide: boolean;
  24534. /**
  24535. * 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
  24536. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24537. * else in the scene. (Eg. security camera)
  24538. *
  24539. * 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)
  24540. */
  24541. customRenderTargets: RenderTargetTexture[];
  24542. /**
  24543. * When set, the camera will render to this render target instead of the default canvas
  24544. *
  24545. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24546. */
  24547. outputRenderTarget: Nullable<RenderTargetTexture>;
  24548. /**
  24549. * Observable triggered when the camera view matrix has changed.
  24550. */
  24551. onViewMatrixChangedObservable: Observable<Camera>;
  24552. /**
  24553. * Observable triggered when the camera Projection matrix has changed.
  24554. */
  24555. onProjectionMatrixChangedObservable: Observable<Camera>;
  24556. /**
  24557. * Observable triggered when the inputs have been processed.
  24558. */
  24559. onAfterCheckInputsObservable: Observable<Camera>;
  24560. /**
  24561. * Observable triggered when reset has been called and applied to the camera.
  24562. */
  24563. onRestoreStateObservable: Observable<Camera>;
  24564. /** @hidden */
  24565. _cameraRigParams: any;
  24566. /** @hidden */
  24567. _rigCameras: Camera[];
  24568. /** @hidden */
  24569. _rigPostProcess: Nullable<PostProcess>;
  24570. protected _webvrViewMatrix: Matrix;
  24571. /** @hidden */
  24572. _skipRendering: boolean;
  24573. /** @hidden */
  24574. _projectionMatrix: Matrix;
  24575. /** @hidden */
  24576. _postProcesses: Nullable<PostProcess>[];
  24577. /** @hidden */
  24578. _activeMeshes: SmartArray<AbstractMesh>;
  24579. protected _globalPosition: Vector3;
  24580. /** @hidden */
  24581. _computedViewMatrix: Matrix;
  24582. private _doNotComputeProjectionMatrix;
  24583. private _transformMatrix;
  24584. private _frustumPlanes;
  24585. private _refreshFrustumPlanes;
  24586. private _storedFov;
  24587. private _stateStored;
  24588. /**
  24589. * Instantiates a new camera object.
  24590. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24591. * @see http://doc.babylonjs.com/features/cameras
  24592. * @param name Defines the name of the camera in the scene
  24593. * @param position Defines the position of the camera
  24594. * @param scene Defines the scene the camera belongs too
  24595. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24596. */
  24597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24598. /**
  24599. * Store current camera state (fov, position, etc..)
  24600. * @returns the camera
  24601. */
  24602. storeState(): Camera;
  24603. /**
  24604. * Restores the camera state values if it has been stored. You must call storeState() first
  24605. */
  24606. protected _restoreStateValues(): boolean;
  24607. /**
  24608. * Restored camera state. You must call storeState() first.
  24609. * @returns true if restored and false otherwise
  24610. */
  24611. restoreState(): boolean;
  24612. /**
  24613. * Gets the class name of the camera.
  24614. * @returns the class name
  24615. */
  24616. getClassName(): string;
  24617. /** @hidden */
  24618. readonly _isCamera: boolean;
  24619. /**
  24620. * Gets a string representation of the camera useful for debug purpose.
  24621. * @param fullDetails Defines that a more verboe level of logging is required
  24622. * @returns the string representation
  24623. */
  24624. toString(fullDetails?: boolean): string;
  24625. /**
  24626. * Gets the current world space position of the camera.
  24627. */
  24628. readonly globalPosition: Vector3;
  24629. /**
  24630. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24631. * @returns the active meshe list
  24632. */
  24633. getActiveMeshes(): SmartArray<AbstractMesh>;
  24634. /**
  24635. * Check wether a mesh is part of the current active mesh list of the camera
  24636. * @param mesh Defines the mesh to check
  24637. * @returns true if active, false otherwise
  24638. */
  24639. isActiveMesh(mesh: Mesh): boolean;
  24640. /**
  24641. * Is this camera ready to be used/rendered
  24642. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24643. * @return true if the camera is ready
  24644. */
  24645. isReady(completeCheck?: boolean): boolean;
  24646. /** @hidden */
  24647. _initCache(): void;
  24648. /** @hidden */
  24649. _updateCache(ignoreParentClass?: boolean): void;
  24650. /** @hidden */
  24651. _isSynchronized(): boolean;
  24652. /** @hidden */
  24653. _isSynchronizedViewMatrix(): boolean;
  24654. /** @hidden */
  24655. _isSynchronizedProjectionMatrix(): boolean;
  24656. /**
  24657. * Attach the input controls to a specific dom element to get the input from.
  24658. * @param element Defines the element the controls should be listened from
  24659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24660. */
  24661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24662. /**
  24663. * Detach the current controls from the specified dom element.
  24664. * @param element Defines the element to stop listening the inputs from
  24665. */
  24666. detachControl(element: HTMLElement): void;
  24667. /**
  24668. * Update the camera state according to the different inputs gathered during the frame.
  24669. */
  24670. update(): void;
  24671. /** @hidden */
  24672. _checkInputs(): void;
  24673. /** @hidden */
  24674. readonly rigCameras: Camera[];
  24675. /**
  24676. * Gets the post process used by the rig cameras
  24677. */
  24678. readonly rigPostProcess: Nullable<PostProcess>;
  24679. /**
  24680. * Internal, gets the first post proces.
  24681. * @returns the first post process to be run on this camera.
  24682. */
  24683. _getFirstPostProcess(): Nullable<PostProcess>;
  24684. private _cascadePostProcessesToRigCams;
  24685. /**
  24686. * Attach a post process to the camera.
  24687. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24688. * @param postProcess The post process to attach to the camera
  24689. * @param insertAt The position of the post process in case several of them are in use in the scene
  24690. * @returns the position the post process has been inserted at
  24691. */
  24692. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24693. /**
  24694. * Detach a post process to the camera.
  24695. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24696. * @param postProcess The post process to detach from the camera
  24697. */
  24698. detachPostProcess(postProcess: PostProcess): void;
  24699. /**
  24700. * Gets the current world matrix of the camera
  24701. */
  24702. getWorldMatrix(): Matrix;
  24703. /** @hidden */
  24704. _getViewMatrix(): Matrix;
  24705. /**
  24706. * Gets the current view matrix of the camera.
  24707. * @param force forces the camera to recompute the matrix without looking at the cached state
  24708. * @returns the view matrix
  24709. */
  24710. getViewMatrix(force?: boolean): Matrix;
  24711. /**
  24712. * Freeze the projection matrix.
  24713. * It will prevent the cache check of the camera projection compute and can speed up perf
  24714. * if no parameter of the camera are meant to change
  24715. * @param projection Defines manually a projection if necessary
  24716. */
  24717. freezeProjectionMatrix(projection?: Matrix): void;
  24718. /**
  24719. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24720. */
  24721. unfreezeProjectionMatrix(): void;
  24722. /**
  24723. * Gets the current projection matrix of the camera.
  24724. * @param force forces the camera to recompute the matrix without looking at the cached state
  24725. * @returns the projection matrix
  24726. */
  24727. getProjectionMatrix(force?: boolean): Matrix;
  24728. /**
  24729. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24730. * @returns a Matrix
  24731. */
  24732. getTransformationMatrix(): Matrix;
  24733. private _updateFrustumPlanes;
  24734. /**
  24735. * Checks if a cullable object (mesh...) is in the camera frustum
  24736. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24737. * @param target The object to check
  24738. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24739. * @returns true if the object is in frustum otherwise false
  24740. */
  24741. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24742. /**
  24743. * Checks if a cullable object (mesh...) is in the camera frustum
  24744. * Unlike isInFrustum this cheks the full bounding box
  24745. * @param target The object to check
  24746. * @returns true if the object is in frustum otherwise false
  24747. */
  24748. isCompletelyInFrustum(target: ICullable): boolean;
  24749. /**
  24750. * Gets a ray in the forward direction from the camera.
  24751. * @param length Defines the length of the ray to create
  24752. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24753. * @param origin Defines the start point of the ray which defaults to the camera position
  24754. * @returns the forward ray
  24755. */
  24756. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24757. /**
  24758. * Releases resources associated with this node.
  24759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24761. */
  24762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24763. /** @hidden */
  24764. _isLeftCamera: boolean;
  24765. /**
  24766. * Gets the left camera of a rig setup in case of Rigged Camera
  24767. */
  24768. readonly isLeftCamera: boolean;
  24769. /** @hidden */
  24770. _isRightCamera: boolean;
  24771. /**
  24772. * Gets the right camera of a rig setup in case of Rigged Camera
  24773. */
  24774. readonly isRightCamera: boolean;
  24775. /**
  24776. * Gets the left camera of a rig setup in case of Rigged Camera
  24777. */
  24778. readonly leftCamera: Nullable<FreeCamera>;
  24779. /**
  24780. * Gets the right camera of a rig setup in case of Rigged Camera
  24781. */
  24782. readonly rightCamera: Nullable<FreeCamera>;
  24783. /**
  24784. * Gets the left camera target of a rig setup in case of Rigged Camera
  24785. * @returns the target position
  24786. */
  24787. getLeftTarget(): Nullable<Vector3>;
  24788. /**
  24789. * Gets the right camera target of a rig setup in case of Rigged Camera
  24790. * @returns the target position
  24791. */
  24792. getRightTarget(): Nullable<Vector3>;
  24793. /**
  24794. * @hidden
  24795. */
  24796. setCameraRigMode(mode: number, rigParams: any): void;
  24797. /** @hidden */
  24798. static _setStereoscopicRigMode(camera: Camera): void;
  24799. /** @hidden */
  24800. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24801. /** @hidden */
  24802. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24803. /** @hidden */
  24804. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24805. /** @hidden */
  24806. _getVRProjectionMatrix(): Matrix;
  24807. protected _updateCameraRotationMatrix(): void;
  24808. protected _updateWebVRCameraRotationMatrix(): void;
  24809. /**
  24810. * This function MUST be overwritten by the different WebVR cameras available.
  24811. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24812. * @hidden
  24813. */
  24814. _getWebVRProjectionMatrix(): Matrix;
  24815. /**
  24816. * This function MUST be overwritten by the different WebVR cameras available.
  24817. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24818. * @hidden
  24819. */
  24820. _getWebVRViewMatrix(): Matrix;
  24821. /** @hidden */
  24822. setCameraRigParameter(name: string, value: any): void;
  24823. /**
  24824. * needs to be overridden by children so sub has required properties to be copied
  24825. * @hidden
  24826. */
  24827. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24828. /**
  24829. * May need to be overridden by children
  24830. * @hidden
  24831. */
  24832. _updateRigCameras(): void;
  24833. /** @hidden */
  24834. _setupInputs(): void;
  24835. /**
  24836. * Serialiaze the camera setup to a json represention
  24837. * @returns the JSON representation
  24838. */
  24839. serialize(): any;
  24840. /**
  24841. * Clones the current camera.
  24842. * @param name The cloned camera name
  24843. * @returns the cloned camera
  24844. */
  24845. clone(name: string): Camera;
  24846. /**
  24847. * Gets the direction of the camera relative to a given local axis.
  24848. * @param localAxis Defines the reference axis to provide a relative direction.
  24849. * @return the direction
  24850. */
  24851. getDirection(localAxis: Vector3): Vector3;
  24852. /**
  24853. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24854. * @param localAxis Defines the reference axis to provide a relative direction.
  24855. * @param result Defines the vector to store the result in
  24856. */
  24857. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24858. /**
  24859. * Gets a camera constructor for a given camera type
  24860. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24861. * @param name The name of the camera the result will be able to instantiate
  24862. * @param scene The scene the result will construct the camera in
  24863. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24864. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24865. * @returns a factory method to construc the camera
  24866. */
  24867. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24868. /**
  24869. * Compute the world matrix of the camera.
  24870. * @returns the camera workd matrix
  24871. */
  24872. computeWorldMatrix(): Matrix;
  24873. /**
  24874. * Parse a JSON and creates the camera from the parsed information
  24875. * @param parsedCamera The JSON to parse
  24876. * @param scene The scene to instantiate the camera in
  24877. * @returns the newly constructed camera
  24878. */
  24879. static Parse(parsedCamera: any, scene: Scene): Camera;
  24880. }
  24881. }
  24882. declare module BABYLON {
  24883. /**
  24884. * Class containing static functions to help procedurally build meshes
  24885. */
  24886. export class DiscBuilder {
  24887. /**
  24888. * Creates a plane polygonal mesh. By default, this is a disc
  24889. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24890. * * 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
  24891. * * 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
  24892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24893. * * 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
  24894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24895. * @param name defines the name of the mesh
  24896. * @param options defines the options used to create the mesh
  24897. * @param scene defines the hosting scene
  24898. * @returns the plane polygonal mesh
  24899. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24900. */
  24901. static CreateDisc(name: string, options: {
  24902. radius?: number;
  24903. tessellation?: number;
  24904. arc?: number;
  24905. updatable?: boolean;
  24906. sideOrientation?: number;
  24907. frontUVs?: Vector4;
  24908. backUVs?: Vector4;
  24909. }, scene?: Nullable<Scene>): Mesh;
  24910. }
  24911. }
  24912. declare module BABYLON {
  24913. /**
  24914. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24915. *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.
  24916. * The SPS is also a particle system. It provides some methods to manage the particles.
  24917. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24918. *
  24919. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24920. */
  24921. export class SolidParticleSystem implements IDisposable {
  24922. /**
  24923. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24924. * Example : var p = SPS.particles[i];
  24925. */
  24926. particles: SolidParticle[];
  24927. /**
  24928. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24929. */
  24930. nbParticles: number;
  24931. /**
  24932. * If the particles must ever face the camera (default false). Useful for planar particles.
  24933. */
  24934. billboard: boolean;
  24935. /**
  24936. * Recompute normals when adding a shape
  24937. */
  24938. recomputeNormals: boolean;
  24939. /**
  24940. * This a counter ofr your own usage. It's not set by any SPS functions.
  24941. */
  24942. counter: number;
  24943. /**
  24944. * The SPS name. This name is also given to the underlying mesh.
  24945. */
  24946. name: string;
  24947. /**
  24948. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24949. */
  24950. mesh: Mesh;
  24951. /**
  24952. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24953. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24954. */
  24955. vars: any;
  24956. /**
  24957. * This array is populated when the SPS is set as 'pickable'.
  24958. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24959. * Each element of this array is an object `{idx: int, faceId: int}`.
  24960. * `idx` is the picked particle index in the `SPS.particles` array
  24961. * `faceId` is the picked face index counted within this particle.
  24962. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24963. */
  24964. pickedParticles: {
  24965. idx: number;
  24966. faceId: number;
  24967. }[];
  24968. /**
  24969. * This array is populated when `enableDepthSort` is set to true.
  24970. * Each element of this array is an instance of the class DepthSortedParticle.
  24971. */
  24972. depthSortedParticles: DepthSortedParticle[];
  24973. /**
  24974. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24975. * @hidden
  24976. */
  24977. _bSphereOnly: boolean;
  24978. /**
  24979. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24980. * @hidden
  24981. */
  24982. _bSphereRadiusFactor: number;
  24983. private _scene;
  24984. private _positions;
  24985. private _indices;
  24986. private _normals;
  24987. private _colors;
  24988. private _uvs;
  24989. private _indices32;
  24990. private _positions32;
  24991. private _normals32;
  24992. private _fixedNormal32;
  24993. private _colors32;
  24994. private _uvs32;
  24995. private _index;
  24996. private _updatable;
  24997. private _pickable;
  24998. private _isVisibilityBoxLocked;
  24999. private _alwaysVisible;
  25000. private _depthSort;
  25001. private _shapeCounter;
  25002. private _copy;
  25003. private _color;
  25004. private _computeParticleColor;
  25005. private _computeParticleTexture;
  25006. private _computeParticleRotation;
  25007. private _computeParticleVertex;
  25008. private _computeBoundingBox;
  25009. private _depthSortParticles;
  25010. private _camera;
  25011. private _mustUnrotateFixedNormals;
  25012. private _particlesIntersect;
  25013. private _needs32Bits;
  25014. /**
  25015. * Creates a SPS (Solid Particle System) object.
  25016. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25017. * @param scene (Scene) is the scene in which the SPS is added.
  25018. * @param options defines the options of the sps e.g.
  25019. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25020. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25021. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25022. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25023. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25024. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25025. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25026. */
  25027. constructor(name: string, scene: Scene, options?: {
  25028. updatable?: boolean;
  25029. isPickable?: boolean;
  25030. enableDepthSort?: boolean;
  25031. particleIntersection?: boolean;
  25032. boundingSphereOnly?: boolean;
  25033. bSphereRadiusFactor?: number;
  25034. });
  25035. /**
  25036. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25037. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25038. * @returns the created mesh
  25039. */
  25040. buildMesh(): Mesh;
  25041. /**
  25042. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25043. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25044. * Thus the particles generated from `digest()` have their property `position` set yet.
  25045. * @param mesh ( Mesh ) is the mesh to be digested
  25046. * @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
  25047. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25048. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25049. * @returns the current SPS
  25050. */
  25051. digest(mesh: Mesh, options?: {
  25052. facetNb?: number;
  25053. number?: number;
  25054. delta?: number;
  25055. }): SolidParticleSystem;
  25056. private _unrotateFixedNormals;
  25057. private _resetCopy;
  25058. private _meshBuilder;
  25059. private _posToShape;
  25060. private _uvsToShapeUV;
  25061. private _addParticle;
  25062. /**
  25063. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25064. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25065. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25066. * @param nb (positive integer) the number of particles to be created from this model
  25067. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25068. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25069. * @returns the number of shapes in the system
  25070. */
  25071. addShape(mesh: Mesh, nb: number, options?: {
  25072. positionFunction?: any;
  25073. vertexFunction?: any;
  25074. }): number;
  25075. private _rebuildParticle;
  25076. /**
  25077. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25078. * @returns the SPS.
  25079. */
  25080. rebuildMesh(): SolidParticleSystem;
  25081. /**
  25082. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25083. * This method calls `updateParticle()` for each particle of the SPS.
  25084. * For an animated SPS, it is usually called within the render loop.
  25085. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25086. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25087. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25088. * @returns the SPS.
  25089. */
  25090. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25091. /**
  25092. * Disposes the SPS.
  25093. */
  25094. dispose(): void;
  25095. /**
  25096. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25098. * @returns the SPS.
  25099. */
  25100. refreshVisibleSize(): SolidParticleSystem;
  25101. /**
  25102. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25103. * @param size the size (float) of the visibility box
  25104. * note : this doesn't lock the SPS mesh bounding box.
  25105. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25106. */
  25107. setVisibilityBox(size: number): void;
  25108. /**
  25109. * Gets whether the SPS as always visible or not
  25110. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25111. */
  25112. /**
  25113. * Sets the SPS as always visible or not
  25114. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25115. */
  25116. isAlwaysVisible: boolean;
  25117. /**
  25118. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25119. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25120. */
  25121. /**
  25122. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25123. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25124. */
  25125. isVisibilityBoxLocked: boolean;
  25126. /**
  25127. * Tells to `setParticles()` to compute the particle rotations or not.
  25128. * Default value : true. The SPS is faster when it's set to false.
  25129. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25130. */
  25131. /**
  25132. * Gets if `setParticles()` computes the particle rotations or not.
  25133. * Default value : true. The SPS is faster when it's set to false.
  25134. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25135. */
  25136. computeParticleRotation: boolean;
  25137. /**
  25138. * Tells to `setParticles()` to compute the particle colors or not.
  25139. * Default value : true. The SPS is faster when it's set to false.
  25140. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25141. */
  25142. /**
  25143. * Gets if `setParticles()` computes the particle colors or not.
  25144. * Default value : true. The SPS is faster when it's set to false.
  25145. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25146. */
  25147. computeParticleColor: boolean;
  25148. /**
  25149. * Gets if `setParticles()` computes the particle textures or not.
  25150. * Default value : true. The SPS is faster when it's set to false.
  25151. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25152. */
  25153. computeParticleTexture: boolean;
  25154. /**
  25155. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25156. * Default value : false. The SPS is faster when it's set to false.
  25157. * Note : the particle custom vertex positions aren't stored values.
  25158. */
  25159. /**
  25160. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25161. * Default value : false. The SPS is faster when it's set to false.
  25162. * Note : the particle custom vertex positions aren't stored values.
  25163. */
  25164. computeParticleVertex: boolean;
  25165. /**
  25166. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25167. */
  25168. /**
  25169. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25170. */
  25171. computeBoundingBox: boolean;
  25172. /**
  25173. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25174. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25175. * Default : `true`
  25176. */
  25177. /**
  25178. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25179. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25180. * Default : `true`
  25181. */
  25182. depthSortParticles: boolean;
  25183. /**
  25184. * This function does nothing. It may be overwritten to set all the particle first values.
  25185. * The SPS doesn't call this function, you may have to call it by your own.
  25186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25187. */
  25188. initParticles(): void;
  25189. /**
  25190. * This function does nothing. It may be overwritten to recycle a particle.
  25191. * The SPS doesn't call this function, you may have to call it by your own.
  25192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25193. * @param particle The particle to recycle
  25194. * @returns the recycled particle
  25195. */
  25196. recycleParticle(particle: SolidParticle): SolidParticle;
  25197. /**
  25198. * Updates a particle : this function should be overwritten by the user.
  25199. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25201. * @example : just set a particle position or velocity and recycle conditions
  25202. * @param particle The particle to update
  25203. * @returns the updated particle
  25204. */
  25205. updateParticle(particle: SolidParticle): SolidParticle;
  25206. /**
  25207. * Updates a vertex of a particle : it can be overwritten by the user.
  25208. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25209. * @param particle the current particle
  25210. * @param vertex the current index of the current particle
  25211. * @param pt the index of the current vertex in the particle shape
  25212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25213. * @example : just set a vertex particle position
  25214. * @returns the updated vertex
  25215. */
  25216. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25217. /**
  25218. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25219. * This does nothing and may be overwritten by the user.
  25220. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25221. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25222. * @param update the boolean update value actually passed to setParticles()
  25223. */
  25224. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25225. /**
  25226. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25227. * This will be passed three parameters.
  25228. * This does nothing and may be overwritten by the user.
  25229. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25230. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25231. * @param update the boolean update value actually passed to setParticles()
  25232. */
  25233. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25234. }
  25235. }
  25236. declare module BABYLON {
  25237. /**
  25238. * Represents one particle of a solid particle system.
  25239. */
  25240. export class SolidParticle {
  25241. /**
  25242. * particle global index
  25243. */
  25244. idx: number;
  25245. /**
  25246. * The color of the particle
  25247. */
  25248. color: Nullable<Color4>;
  25249. /**
  25250. * The world space position of the particle.
  25251. */
  25252. position: Vector3;
  25253. /**
  25254. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25255. */
  25256. rotation: Vector3;
  25257. /**
  25258. * The world space rotation quaternion of the particle.
  25259. */
  25260. rotationQuaternion: Nullable<Quaternion>;
  25261. /**
  25262. * The scaling of the particle.
  25263. */
  25264. scaling: Vector3;
  25265. /**
  25266. * The uvs of the particle.
  25267. */
  25268. uvs: Vector4;
  25269. /**
  25270. * The current speed of the particle.
  25271. */
  25272. velocity: Vector3;
  25273. /**
  25274. * The pivot point in the particle local space.
  25275. */
  25276. pivot: Vector3;
  25277. /**
  25278. * Must the particle be translated from its pivot point in its local space ?
  25279. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25280. * Default : false
  25281. */
  25282. translateFromPivot: boolean;
  25283. /**
  25284. * Is the particle active or not ?
  25285. */
  25286. alive: boolean;
  25287. /**
  25288. * Is the particle visible or not ?
  25289. */
  25290. isVisible: boolean;
  25291. /**
  25292. * Index of this particle in the global "positions" array (Internal use)
  25293. * @hidden
  25294. */
  25295. _pos: number;
  25296. /**
  25297. * @hidden Index of this particle in the global "indices" array (Internal use)
  25298. */
  25299. _ind: number;
  25300. /**
  25301. * @hidden ModelShape of this particle (Internal use)
  25302. */
  25303. _model: ModelShape;
  25304. /**
  25305. * ModelShape id of this particle
  25306. */
  25307. shapeId: number;
  25308. /**
  25309. * Index of the particle in its shape id (Internal use)
  25310. */
  25311. idxInShape: number;
  25312. /**
  25313. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25314. */
  25315. _modelBoundingInfo: BoundingInfo;
  25316. /**
  25317. * @hidden Particle BoundingInfo object (Internal use)
  25318. */
  25319. _boundingInfo: BoundingInfo;
  25320. /**
  25321. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25322. */
  25323. _sps: SolidParticleSystem;
  25324. /**
  25325. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25326. */
  25327. _stillInvisible: boolean;
  25328. /**
  25329. * @hidden Last computed particle rotation matrix
  25330. */
  25331. _rotationMatrix: number[];
  25332. /**
  25333. * Parent particle Id, if any.
  25334. * Default null.
  25335. */
  25336. parentId: Nullable<number>;
  25337. /**
  25338. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25339. * The possible values are :
  25340. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25341. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25342. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25343. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25344. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25345. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25346. * */
  25347. cullingStrategy: number;
  25348. /**
  25349. * @hidden Internal global position in the SPS.
  25350. */
  25351. _globalPosition: Vector3;
  25352. /**
  25353. * Creates a Solid Particle object.
  25354. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25355. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25356. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25357. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25358. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25359. * @param shapeId (integer) is the model shape identifier in the SPS.
  25360. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25361. * @param sps defines the sps it is associated to
  25362. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25363. */
  25364. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25365. /**
  25366. * Legacy support, changed scale to scaling
  25367. */
  25368. /**
  25369. * Legacy support, changed scale to scaling
  25370. */
  25371. scale: Vector3;
  25372. /**
  25373. * Legacy support, changed quaternion to rotationQuaternion
  25374. */
  25375. /**
  25376. * Legacy support, changed quaternion to rotationQuaternion
  25377. */
  25378. quaternion: Nullable<Quaternion>;
  25379. /**
  25380. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25381. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25382. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25383. * @returns true if it intersects
  25384. */
  25385. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25386. /**
  25387. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25388. * A particle is in the frustum if its bounding box intersects the frustum
  25389. * @param frustumPlanes defines the frustum to test
  25390. * @returns true if the particle is in the frustum planes
  25391. */
  25392. isInFrustum(frustumPlanes: Plane[]): boolean;
  25393. /**
  25394. * get the rotation matrix of the particle
  25395. * @hidden
  25396. */
  25397. getRotationMatrix(m: Matrix): void;
  25398. }
  25399. /**
  25400. * Represents the shape of the model used by one particle of a solid particle system.
  25401. * SPS internal tool, don't use it manually.
  25402. */
  25403. export class ModelShape {
  25404. /**
  25405. * The shape id
  25406. * @hidden
  25407. */
  25408. shapeID: number;
  25409. /**
  25410. * flat array of model positions (internal use)
  25411. * @hidden
  25412. */
  25413. _shape: Vector3[];
  25414. /**
  25415. * flat array of model UVs (internal use)
  25416. * @hidden
  25417. */
  25418. _shapeUV: number[];
  25419. /**
  25420. * length of the shape in the model indices array (internal use)
  25421. * @hidden
  25422. */
  25423. _indicesLength: number;
  25424. /**
  25425. * Custom position function (internal use)
  25426. * @hidden
  25427. */
  25428. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25429. /**
  25430. * Custom vertex function (internal use)
  25431. * @hidden
  25432. */
  25433. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25434. /**
  25435. * 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.
  25436. * SPS internal tool, don't use it manually.
  25437. * @hidden
  25438. */
  25439. 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>);
  25440. }
  25441. /**
  25442. * Represents a Depth Sorted Particle in the solid particle system.
  25443. */
  25444. export class DepthSortedParticle {
  25445. /**
  25446. * Index of the particle in the "indices" array
  25447. */
  25448. ind: number;
  25449. /**
  25450. * Length of the particle shape in the "indices" array
  25451. */
  25452. indicesLength: number;
  25453. /**
  25454. * Squared distance from the particle to the camera
  25455. */
  25456. sqDistance: number;
  25457. }
  25458. }
  25459. declare module BABYLON {
  25460. /**
  25461. * @hidden
  25462. */
  25463. export class _MeshCollisionData {
  25464. _checkCollisions: boolean;
  25465. _collisionMask: number;
  25466. _collisionGroup: number;
  25467. _collider: Nullable<Collider>;
  25468. _oldPositionForCollisions: Vector3;
  25469. _diffPositionForCollisions: Vector3;
  25470. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25471. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25472. }
  25473. }
  25474. declare module BABYLON {
  25475. /** @hidden */
  25476. class _FacetDataStorage {
  25477. facetPositions: Vector3[];
  25478. facetNormals: Vector3[];
  25479. facetPartitioning: number[][];
  25480. facetNb: number;
  25481. partitioningSubdivisions: number;
  25482. partitioningBBoxRatio: number;
  25483. facetDataEnabled: boolean;
  25484. facetParameters: any;
  25485. bbSize: Vector3;
  25486. subDiv: {
  25487. max: number;
  25488. X: number;
  25489. Y: number;
  25490. Z: number;
  25491. };
  25492. facetDepthSort: boolean;
  25493. facetDepthSortEnabled: boolean;
  25494. depthSortedIndices: IndicesArray;
  25495. depthSortedFacets: {
  25496. ind: number;
  25497. sqDistance: number;
  25498. }[];
  25499. facetDepthSortFunction: (f1: {
  25500. ind: number;
  25501. sqDistance: number;
  25502. }, f2: {
  25503. ind: number;
  25504. sqDistance: number;
  25505. }) => number;
  25506. facetDepthSortFrom: Vector3;
  25507. facetDepthSortOrigin: Vector3;
  25508. invertedMatrix: Matrix;
  25509. }
  25510. /**
  25511. * @hidden
  25512. **/
  25513. class _InternalAbstractMeshDataInfo {
  25514. _hasVertexAlpha: boolean;
  25515. _useVertexColors: boolean;
  25516. _numBoneInfluencers: number;
  25517. _applyFog: boolean;
  25518. _receiveShadows: boolean;
  25519. _facetData: _FacetDataStorage;
  25520. _visibility: number;
  25521. _skeleton: Nullable<Skeleton>;
  25522. _layerMask: number;
  25523. _computeBonesUsingShaders: boolean;
  25524. _isActive: boolean;
  25525. _onlyForInstances: boolean;
  25526. _isActiveIntermediate: boolean;
  25527. _onlyForInstancesIntermediate: boolean;
  25528. }
  25529. /**
  25530. * Class used to store all common mesh properties
  25531. */
  25532. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25533. /** No occlusion */
  25534. static OCCLUSION_TYPE_NONE: number;
  25535. /** Occlusion set to optimisitic */
  25536. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25537. /** Occlusion set to strict */
  25538. static OCCLUSION_TYPE_STRICT: number;
  25539. /** Use an accurante occlusion algorithm */
  25540. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25541. /** Use a conservative occlusion algorithm */
  25542. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25543. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25544. * Test order :
  25545. * Is the bounding sphere outside the frustum ?
  25546. * If not, are the bounding box vertices outside the frustum ?
  25547. * It not, then the cullable object is in the frustum.
  25548. */
  25549. static readonly CULLINGSTRATEGY_STANDARD: number;
  25550. /** Culling strategy : Bounding Sphere Only.
  25551. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25552. * It's also less accurate than the standard because some not visible objects can still be selected.
  25553. * Test : is the bounding sphere outside the frustum ?
  25554. * If not, then the cullable object is in the frustum.
  25555. */
  25556. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25557. /** Culling strategy : Optimistic Inclusion.
  25558. * This in an inclusion test first, then the standard exclusion test.
  25559. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25560. * 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.
  25561. * Anyway, it's as accurate as the standard strategy.
  25562. * Test :
  25563. * Is the cullable object bounding sphere center in the frustum ?
  25564. * If not, apply the default culling strategy.
  25565. */
  25566. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25567. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25568. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25569. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25570. * 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.
  25571. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25572. * Test :
  25573. * Is the cullable object bounding sphere center in the frustum ?
  25574. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25575. */
  25576. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25577. /**
  25578. * No billboard
  25579. */
  25580. static readonly BILLBOARDMODE_NONE: number;
  25581. /** Billboard on X axis */
  25582. static readonly BILLBOARDMODE_X: number;
  25583. /** Billboard on Y axis */
  25584. static readonly BILLBOARDMODE_Y: number;
  25585. /** Billboard on Z axis */
  25586. static readonly BILLBOARDMODE_Z: number;
  25587. /** Billboard on all axes */
  25588. static readonly BILLBOARDMODE_ALL: number;
  25589. /** Billboard on using position instead of orientation */
  25590. static readonly BILLBOARDMODE_USE_POSITION: number;
  25591. /** @hidden */
  25592. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25593. /**
  25594. * The culling strategy to use to check whether the mesh must be rendered or not.
  25595. * This value can be changed at any time and will be used on the next render mesh selection.
  25596. * The possible values are :
  25597. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25598. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25599. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25600. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25601. * Please read each static variable documentation to get details about the culling process.
  25602. * */
  25603. cullingStrategy: number;
  25604. /**
  25605. * Gets the number of facets in the mesh
  25606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25607. */
  25608. readonly facetNb: number;
  25609. /**
  25610. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25612. */
  25613. partitioningSubdivisions: number;
  25614. /**
  25615. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25616. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25618. */
  25619. partitioningBBoxRatio: number;
  25620. /**
  25621. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25622. * Works only for updatable meshes.
  25623. * Doesn't work with multi-materials
  25624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25625. */
  25626. mustDepthSortFacets: boolean;
  25627. /**
  25628. * The location (Vector3) where the facet depth sort must be computed from.
  25629. * By default, the active camera position.
  25630. * Used only when facet depth sort is enabled
  25631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25632. */
  25633. facetDepthSortFrom: Vector3;
  25634. /**
  25635. * gets a boolean indicating if facetData is enabled
  25636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25637. */
  25638. readonly isFacetDataEnabled: boolean;
  25639. /** @hidden */
  25640. _updateNonUniformScalingState(value: boolean): boolean;
  25641. /**
  25642. * An event triggered when this mesh collides with another one
  25643. */
  25644. onCollideObservable: Observable<AbstractMesh>;
  25645. /** Set a function to call when this mesh collides with another one */
  25646. onCollide: () => void;
  25647. /**
  25648. * An event triggered when the collision's position changes
  25649. */
  25650. onCollisionPositionChangeObservable: Observable<Vector3>;
  25651. /** Set a function to call when the collision's position changes */
  25652. onCollisionPositionChange: () => void;
  25653. /**
  25654. * An event triggered when material is changed
  25655. */
  25656. onMaterialChangedObservable: Observable<AbstractMesh>;
  25657. /**
  25658. * Gets or sets the orientation for POV movement & rotation
  25659. */
  25660. definedFacingForward: boolean;
  25661. /** @hidden */
  25662. _occlusionQuery: Nullable<WebGLQuery>;
  25663. /** @hidden */
  25664. _renderingGroup: Nullable<RenderingGroup>;
  25665. /**
  25666. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25667. */
  25668. /**
  25669. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25670. */
  25671. visibility: number;
  25672. /** Gets or sets the alpha index used to sort transparent meshes
  25673. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25674. */
  25675. alphaIndex: number;
  25676. /**
  25677. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25678. */
  25679. isVisible: boolean;
  25680. /**
  25681. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25682. */
  25683. isPickable: boolean;
  25684. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25685. showSubMeshesBoundingBox: boolean;
  25686. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25687. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25688. */
  25689. isBlocker: boolean;
  25690. /**
  25691. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25692. */
  25693. enablePointerMoveEvents: boolean;
  25694. /**
  25695. * Specifies the rendering group id for this mesh (0 by default)
  25696. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25697. */
  25698. renderingGroupId: number;
  25699. private _material;
  25700. /** Gets or sets current material */
  25701. material: Nullable<Material>;
  25702. /**
  25703. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25704. * @see http://doc.babylonjs.com/babylon101/shadows
  25705. */
  25706. receiveShadows: boolean;
  25707. /** Defines color to use when rendering outline */
  25708. outlineColor: Color3;
  25709. /** Define width to use when rendering outline */
  25710. outlineWidth: number;
  25711. /** Defines color to use when rendering overlay */
  25712. overlayColor: Color3;
  25713. /** Defines alpha to use when rendering overlay */
  25714. overlayAlpha: number;
  25715. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25716. hasVertexAlpha: boolean;
  25717. /** 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) */
  25718. useVertexColors: boolean;
  25719. /**
  25720. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25721. */
  25722. computeBonesUsingShaders: boolean;
  25723. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25724. numBoneInfluencers: number;
  25725. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25726. applyFog: boolean;
  25727. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25728. useOctreeForRenderingSelection: boolean;
  25729. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25730. useOctreeForPicking: boolean;
  25731. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25732. useOctreeForCollisions: boolean;
  25733. /**
  25734. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25735. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25736. */
  25737. layerMask: number;
  25738. /**
  25739. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25740. */
  25741. alwaysSelectAsActiveMesh: boolean;
  25742. /**
  25743. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25744. */
  25745. doNotSyncBoundingInfo: boolean;
  25746. /**
  25747. * Gets or sets the current action manager
  25748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25749. */
  25750. actionManager: Nullable<AbstractActionManager>;
  25751. private _meshCollisionData;
  25752. /**
  25753. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25755. */
  25756. ellipsoid: Vector3;
  25757. /**
  25758. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25760. */
  25761. ellipsoidOffset: Vector3;
  25762. /**
  25763. * Gets or sets a collision mask used to mask collisions (default is -1).
  25764. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25765. */
  25766. collisionMask: number;
  25767. /**
  25768. * Gets or sets the current collision group mask (-1 by default).
  25769. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25770. */
  25771. collisionGroup: number;
  25772. /**
  25773. * Defines edge width used when edgesRenderer is enabled
  25774. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25775. */
  25776. edgesWidth: number;
  25777. /**
  25778. * Defines edge color used when edgesRenderer is enabled
  25779. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25780. */
  25781. edgesColor: Color4;
  25782. /** @hidden */
  25783. _edgesRenderer: Nullable<IEdgesRenderer>;
  25784. /** @hidden */
  25785. _masterMesh: Nullable<AbstractMesh>;
  25786. /** @hidden */
  25787. _boundingInfo: Nullable<BoundingInfo>;
  25788. /** @hidden */
  25789. _renderId: number;
  25790. /**
  25791. * Gets or sets the list of subMeshes
  25792. * @see http://doc.babylonjs.com/how_to/multi_materials
  25793. */
  25794. subMeshes: SubMesh[];
  25795. /** @hidden */
  25796. _intersectionsInProgress: AbstractMesh[];
  25797. /** @hidden */
  25798. _unIndexed: boolean;
  25799. /** @hidden */
  25800. _lightSources: Light[];
  25801. /** Gets the list of lights affecting that mesh */
  25802. readonly lightSources: Light[];
  25803. /** @hidden */
  25804. readonly _positions: Nullable<Vector3[]>;
  25805. /** @hidden */
  25806. _waitingData: {
  25807. lods: Nullable<any>;
  25808. actions: Nullable<any>;
  25809. freezeWorldMatrix: Nullable<boolean>;
  25810. };
  25811. /** @hidden */
  25812. _bonesTransformMatrices: Nullable<Float32Array>;
  25813. /** @hidden */
  25814. _transformMatrixTexture: Nullable<RawTexture>;
  25815. /**
  25816. * Gets or sets a skeleton to apply skining transformations
  25817. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25818. */
  25819. skeleton: Nullable<Skeleton>;
  25820. /**
  25821. * An event triggered when the mesh is rebuilt.
  25822. */
  25823. onRebuildObservable: Observable<AbstractMesh>;
  25824. /**
  25825. * Creates a new AbstractMesh
  25826. * @param name defines the name of the mesh
  25827. * @param scene defines the hosting scene
  25828. */
  25829. constructor(name: string, scene?: Nullable<Scene>);
  25830. /**
  25831. * Returns the string "AbstractMesh"
  25832. * @returns "AbstractMesh"
  25833. */
  25834. getClassName(): string;
  25835. /**
  25836. * Gets a string representation of the current mesh
  25837. * @param fullDetails defines a boolean indicating if full details must be included
  25838. * @returns a string representation of the current mesh
  25839. */
  25840. toString(fullDetails?: boolean): string;
  25841. /**
  25842. * @hidden
  25843. */
  25844. protected _getEffectiveParent(): Nullable<Node>;
  25845. /** @hidden */
  25846. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25847. /** @hidden */
  25848. _rebuild(): void;
  25849. /** @hidden */
  25850. _resyncLightSources(): void;
  25851. /** @hidden */
  25852. _resyncLighSource(light: Light): void;
  25853. /** @hidden */
  25854. _unBindEffect(): void;
  25855. /** @hidden */
  25856. _removeLightSource(light: Light): void;
  25857. private _markSubMeshesAsDirty;
  25858. /** @hidden */
  25859. _markSubMeshesAsLightDirty(): void;
  25860. /** @hidden */
  25861. _markSubMeshesAsAttributesDirty(): void;
  25862. /** @hidden */
  25863. _markSubMeshesAsMiscDirty(): void;
  25864. /**
  25865. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25866. */
  25867. scaling: Vector3;
  25868. /**
  25869. * Returns true if the mesh is blocked. Implemented by child classes
  25870. */
  25871. readonly isBlocked: boolean;
  25872. /**
  25873. * Returns the mesh itself by default. Implemented by child classes
  25874. * @param camera defines the camera to use to pick the right LOD level
  25875. * @returns the currentAbstractMesh
  25876. */
  25877. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25878. /**
  25879. * Returns 0 by default. Implemented by child classes
  25880. * @returns an integer
  25881. */
  25882. getTotalVertices(): number;
  25883. /**
  25884. * Returns a positive integer : the total number of indices in this mesh geometry.
  25885. * @returns the numner of indices or zero if the mesh has no geometry.
  25886. */
  25887. getTotalIndices(): number;
  25888. /**
  25889. * Returns null by default. Implemented by child classes
  25890. * @returns null
  25891. */
  25892. getIndices(): Nullable<IndicesArray>;
  25893. /**
  25894. * Returns the array of the requested vertex data kind. Implemented by child classes
  25895. * @param kind defines the vertex data kind to use
  25896. * @returns null
  25897. */
  25898. getVerticesData(kind: string): Nullable<FloatArray>;
  25899. /**
  25900. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25901. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25902. * Note that a new underlying VertexBuffer object is created each call.
  25903. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25904. * @param kind defines vertex data kind:
  25905. * * VertexBuffer.PositionKind
  25906. * * VertexBuffer.UVKind
  25907. * * VertexBuffer.UV2Kind
  25908. * * VertexBuffer.UV3Kind
  25909. * * VertexBuffer.UV4Kind
  25910. * * VertexBuffer.UV5Kind
  25911. * * VertexBuffer.UV6Kind
  25912. * * VertexBuffer.ColorKind
  25913. * * VertexBuffer.MatricesIndicesKind
  25914. * * VertexBuffer.MatricesIndicesExtraKind
  25915. * * VertexBuffer.MatricesWeightsKind
  25916. * * VertexBuffer.MatricesWeightsExtraKind
  25917. * @param data defines the data source
  25918. * @param updatable defines if the data must be flagged as updatable (or static)
  25919. * @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
  25920. * @returns the current mesh
  25921. */
  25922. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25923. /**
  25924. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25925. * If the mesh has no geometry, it is simply returned as it is.
  25926. * @param kind defines vertex data kind:
  25927. * * VertexBuffer.PositionKind
  25928. * * VertexBuffer.UVKind
  25929. * * VertexBuffer.UV2Kind
  25930. * * VertexBuffer.UV3Kind
  25931. * * VertexBuffer.UV4Kind
  25932. * * VertexBuffer.UV5Kind
  25933. * * VertexBuffer.UV6Kind
  25934. * * VertexBuffer.ColorKind
  25935. * * VertexBuffer.MatricesIndicesKind
  25936. * * VertexBuffer.MatricesIndicesExtraKind
  25937. * * VertexBuffer.MatricesWeightsKind
  25938. * * VertexBuffer.MatricesWeightsExtraKind
  25939. * @param data defines the data source
  25940. * @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
  25941. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25942. * @returns the current mesh
  25943. */
  25944. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25945. /**
  25946. * Sets the mesh indices,
  25947. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25948. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25949. * @param totalVertices Defines the total number of vertices
  25950. * @returns the current mesh
  25951. */
  25952. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25953. /**
  25954. * Gets a boolean indicating if specific vertex data is present
  25955. * @param kind defines the vertex data kind to use
  25956. * @returns true is data kind is present
  25957. */
  25958. isVerticesDataPresent(kind: string): boolean;
  25959. /**
  25960. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25961. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25962. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25963. * @returns a BoundingInfo
  25964. */
  25965. getBoundingInfo(): BoundingInfo;
  25966. /**
  25967. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25968. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25969. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25970. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25971. * @returns the current mesh
  25972. */
  25973. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25974. /**
  25975. * Overwrite the current bounding info
  25976. * @param boundingInfo defines the new bounding info
  25977. * @returns the current mesh
  25978. */
  25979. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25980. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25981. readonly useBones: boolean;
  25982. /** @hidden */
  25983. _preActivate(): void;
  25984. /** @hidden */
  25985. _preActivateForIntermediateRendering(renderId: number): void;
  25986. /** @hidden */
  25987. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25988. /** @hidden */
  25989. _postActivate(): void;
  25990. /** @hidden */
  25991. _freeze(): void;
  25992. /** @hidden */
  25993. _unFreeze(): void;
  25994. /**
  25995. * Gets the current world matrix
  25996. * @returns a Matrix
  25997. */
  25998. getWorldMatrix(): Matrix;
  25999. /** @hidden */
  26000. _getWorldMatrixDeterminant(): number;
  26001. /**
  26002. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26003. */
  26004. readonly isAnInstance: boolean;
  26005. /**
  26006. * Perform relative position change from the point of view of behind the front of the mesh.
  26007. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26008. * Supports definition of mesh facing forward or backward
  26009. * @param amountRight defines the distance on the right axis
  26010. * @param amountUp defines the distance on the up axis
  26011. * @param amountForward defines the distance on the forward axis
  26012. * @returns the current mesh
  26013. */
  26014. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26015. /**
  26016. * Calculate relative position change from the point of view of behind the front of the mesh.
  26017. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26018. * Supports definition of mesh facing forward or backward
  26019. * @param amountRight defines the distance on the right axis
  26020. * @param amountUp defines the distance on the up axis
  26021. * @param amountForward defines the distance on the forward axis
  26022. * @returns the new displacement vector
  26023. */
  26024. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26025. /**
  26026. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26027. * Supports definition of mesh facing forward or backward
  26028. * @param flipBack defines the flip
  26029. * @param twirlClockwise defines the twirl
  26030. * @param tiltRight defines the tilt
  26031. * @returns the current mesh
  26032. */
  26033. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26034. /**
  26035. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26036. * Supports definition of mesh facing forward or backward.
  26037. * @param flipBack defines the flip
  26038. * @param twirlClockwise defines the twirl
  26039. * @param tiltRight defines the tilt
  26040. * @returns the new rotation vector
  26041. */
  26042. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26043. /**
  26044. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26045. * This means the mesh underlying bounding box and sphere are recomputed.
  26046. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26047. * @returns the current mesh
  26048. */
  26049. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26050. /** @hidden */
  26051. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26052. /** @hidden */
  26053. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26054. /** @hidden */
  26055. _updateBoundingInfo(): AbstractMesh;
  26056. /** @hidden */
  26057. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26058. /** @hidden */
  26059. protected _afterComputeWorldMatrix(): void;
  26060. /** @hidden */
  26061. readonly _effectiveMesh: AbstractMesh;
  26062. /**
  26063. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26064. * A mesh is in the frustum if its bounding box intersects the frustum
  26065. * @param frustumPlanes defines the frustum to test
  26066. * @returns true if the mesh is in the frustum planes
  26067. */
  26068. isInFrustum(frustumPlanes: Plane[]): boolean;
  26069. /**
  26070. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26071. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26072. * @param frustumPlanes defines the frustum to test
  26073. * @returns true if the mesh is completely in the frustum planes
  26074. */
  26075. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26076. /**
  26077. * True if the mesh intersects another mesh or a SolidParticle object
  26078. * @param mesh defines a target mesh or SolidParticle to test
  26079. * @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)
  26080. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26081. * @returns true if there is an intersection
  26082. */
  26083. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26084. /**
  26085. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26086. * @param point defines the point to test
  26087. * @returns true if there is an intersection
  26088. */
  26089. intersectsPoint(point: Vector3): boolean;
  26090. /**
  26091. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26092. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26093. */
  26094. checkCollisions: boolean;
  26095. /**
  26096. * Gets Collider object used to compute collisions (not physics)
  26097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26098. */
  26099. readonly collider: Nullable<Collider>;
  26100. /**
  26101. * Move the mesh using collision engine
  26102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26103. * @param displacement defines the requested displacement vector
  26104. * @returns the current mesh
  26105. */
  26106. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26107. private _onCollisionPositionChange;
  26108. /** @hidden */
  26109. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26110. /** @hidden */
  26111. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26112. /** @hidden */
  26113. _checkCollision(collider: Collider): AbstractMesh;
  26114. /** @hidden */
  26115. _generatePointsArray(): boolean;
  26116. /**
  26117. * Checks if the passed Ray intersects with the mesh
  26118. * @param ray defines the ray to use
  26119. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26120. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26121. * @returns the picking info
  26122. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26123. */
  26124. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26125. /**
  26126. * Clones the current mesh
  26127. * @param name defines the mesh name
  26128. * @param newParent defines the new mesh parent
  26129. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26130. * @returns the new mesh
  26131. */
  26132. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26133. /**
  26134. * Disposes all the submeshes of the current meshnp
  26135. * @returns the current mesh
  26136. */
  26137. releaseSubMeshes(): AbstractMesh;
  26138. /**
  26139. * Releases resources associated with this abstract mesh.
  26140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26142. */
  26143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26144. /**
  26145. * Adds the passed mesh as a child to the current mesh
  26146. * @param mesh defines the child mesh
  26147. * @returns the current mesh
  26148. */
  26149. addChild(mesh: AbstractMesh): AbstractMesh;
  26150. /**
  26151. * Removes the passed mesh from the current mesh children list
  26152. * @param mesh defines the child mesh
  26153. * @returns the current mesh
  26154. */
  26155. removeChild(mesh: AbstractMesh): AbstractMesh;
  26156. /** @hidden */
  26157. private _initFacetData;
  26158. /**
  26159. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26160. * This method can be called within the render loop.
  26161. * 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
  26162. * @returns the current mesh
  26163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26164. */
  26165. updateFacetData(): AbstractMesh;
  26166. /**
  26167. * Returns the facetLocalNormals array.
  26168. * The normals are expressed in the mesh local spac
  26169. * @returns an array of Vector3
  26170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26171. */
  26172. getFacetLocalNormals(): Vector3[];
  26173. /**
  26174. * Returns the facetLocalPositions array.
  26175. * The facet positions are expressed in the mesh local space
  26176. * @returns an array of Vector3
  26177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26178. */
  26179. getFacetLocalPositions(): Vector3[];
  26180. /**
  26181. * Returns the facetLocalPartioning array
  26182. * @returns an array of array of numbers
  26183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26184. */
  26185. getFacetLocalPartitioning(): number[][];
  26186. /**
  26187. * Returns the i-th facet position in the world system.
  26188. * This method allocates a new Vector3 per call
  26189. * @param i defines the facet index
  26190. * @returns a new Vector3
  26191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26192. */
  26193. getFacetPosition(i: number): Vector3;
  26194. /**
  26195. * Sets the reference Vector3 with the i-th facet position in the world system
  26196. * @param i defines the facet index
  26197. * @param ref defines the target vector
  26198. * @returns the current mesh
  26199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26200. */
  26201. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26202. /**
  26203. * Returns the i-th facet normal in the world system.
  26204. * This method allocates a new Vector3 per call
  26205. * @param i defines the facet index
  26206. * @returns a new Vector3
  26207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26208. */
  26209. getFacetNormal(i: number): Vector3;
  26210. /**
  26211. * Sets the reference Vector3 with the i-th facet normal in the world system
  26212. * @param i defines the facet index
  26213. * @param ref defines the target vector
  26214. * @returns the current mesh
  26215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26216. */
  26217. getFacetNormalToRef(i: number, ref: Vector3): this;
  26218. /**
  26219. * 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)
  26220. * @param x defines x coordinate
  26221. * @param y defines y coordinate
  26222. * @param z defines z coordinate
  26223. * @returns the array of facet indexes
  26224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26225. */
  26226. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26227. /**
  26228. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26229. * @param projected sets as the (x,y,z) world projection on the facet
  26230. * @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
  26231. * @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
  26232. * @param x defines x coordinate
  26233. * @param y defines y coordinate
  26234. * @param z defines z coordinate
  26235. * @returns the face index if found (or null instead)
  26236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26237. */
  26238. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26239. /**
  26240. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26241. * @param projected sets as the (x,y,z) local projection on the facet
  26242. * @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
  26243. * @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
  26244. * @param x defines x coordinate
  26245. * @param y defines y coordinate
  26246. * @param z defines z coordinate
  26247. * @returns the face index if found (or null instead)
  26248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26249. */
  26250. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26251. /**
  26252. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26253. * @returns the parameters
  26254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26255. */
  26256. getFacetDataParameters(): any;
  26257. /**
  26258. * Disables the feature FacetData and frees the related memory
  26259. * @returns the current mesh
  26260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26261. */
  26262. disableFacetData(): AbstractMesh;
  26263. /**
  26264. * Updates the AbstractMesh indices array
  26265. * @param indices defines the data source
  26266. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26267. * @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)
  26268. * @returns the current mesh
  26269. */
  26270. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26271. /**
  26272. * Creates new normals data for the mesh
  26273. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26274. * @returns the current mesh
  26275. */
  26276. createNormals(updatable: boolean): AbstractMesh;
  26277. /**
  26278. * Align the mesh with a normal
  26279. * @param normal defines the normal to use
  26280. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26281. * @returns the current mesh
  26282. */
  26283. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26284. /** @hidden */
  26285. _checkOcclusionQuery(): boolean;
  26286. /**
  26287. * Disables the mesh edge rendering mode
  26288. * @returns the currentAbstractMesh
  26289. */
  26290. disableEdgesRendering(): AbstractMesh;
  26291. /**
  26292. * Enables the edge rendering mode on the mesh.
  26293. * This mode makes the mesh edges visible
  26294. * @param epsilon defines the maximal distance between two angles to detect a face
  26295. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26296. * @returns the currentAbstractMesh
  26297. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26298. */
  26299. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26300. }
  26301. }
  26302. declare module BABYLON {
  26303. /**
  26304. * Interface used to define ActionEvent
  26305. */
  26306. export interface IActionEvent {
  26307. /** The mesh or sprite that triggered the action */
  26308. source: any;
  26309. /** The X mouse cursor position at the time of the event */
  26310. pointerX: number;
  26311. /** The Y mouse cursor position at the time of the event */
  26312. pointerY: number;
  26313. /** The mesh that is currently pointed at (can be null) */
  26314. meshUnderPointer: Nullable<AbstractMesh>;
  26315. /** the original (browser) event that triggered the ActionEvent */
  26316. sourceEvent?: any;
  26317. /** additional data for the event */
  26318. additionalData?: any;
  26319. }
  26320. /**
  26321. * ActionEvent is the event being sent when an action is triggered.
  26322. */
  26323. export class ActionEvent implements IActionEvent {
  26324. /** The mesh or sprite that triggered the action */
  26325. source: any;
  26326. /** The X mouse cursor position at the time of the event */
  26327. pointerX: number;
  26328. /** The Y mouse cursor position at the time of the event */
  26329. pointerY: number;
  26330. /** The mesh that is currently pointed at (can be null) */
  26331. meshUnderPointer: Nullable<AbstractMesh>;
  26332. /** the original (browser) event that triggered the ActionEvent */
  26333. sourceEvent?: any;
  26334. /** additional data for the event */
  26335. additionalData?: any;
  26336. /**
  26337. * Creates a new ActionEvent
  26338. * @param source The mesh or sprite that triggered the action
  26339. * @param pointerX The X mouse cursor position at the time of the event
  26340. * @param pointerY The Y mouse cursor position at the time of the event
  26341. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26342. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26343. * @param additionalData additional data for the event
  26344. */
  26345. constructor(
  26346. /** The mesh or sprite that triggered the action */
  26347. source: any,
  26348. /** The X mouse cursor position at the time of the event */
  26349. pointerX: number,
  26350. /** The Y mouse cursor position at the time of the event */
  26351. pointerY: number,
  26352. /** The mesh that is currently pointed at (can be null) */
  26353. meshUnderPointer: Nullable<AbstractMesh>,
  26354. /** the original (browser) event that triggered the ActionEvent */
  26355. sourceEvent?: any,
  26356. /** additional data for the event */
  26357. additionalData?: any);
  26358. /**
  26359. * Helper function to auto-create an ActionEvent from a source mesh.
  26360. * @param source The source mesh that triggered the event
  26361. * @param evt The original (browser) event
  26362. * @param additionalData additional data for the event
  26363. * @returns the new ActionEvent
  26364. */
  26365. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26366. /**
  26367. * Helper function to auto-create an ActionEvent from a source sprite
  26368. * @param source The source sprite that triggered the event
  26369. * @param scene Scene associated with the sprite
  26370. * @param evt The original (browser) event
  26371. * @param additionalData additional data for the event
  26372. * @returns the new ActionEvent
  26373. */
  26374. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26375. /**
  26376. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26377. * @param scene the scene where the event occurred
  26378. * @param evt The original (browser) event
  26379. * @returns the new ActionEvent
  26380. */
  26381. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26382. /**
  26383. * Helper function to auto-create an ActionEvent from a primitive
  26384. * @param prim defines the target primitive
  26385. * @param pointerPos defines the pointer position
  26386. * @param evt The original (browser) event
  26387. * @param additionalData additional data for the event
  26388. * @returns the new ActionEvent
  26389. */
  26390. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26391. }
  26392. }
  26393. declare module BABYLON {
  26394. /**
  26395. * Abstract class used to decouple action Manager from scene and meshes.
  26396. * Do not instantiate.
  26397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26398. */
  26399. export abstract class AbstractActionManager implements IDisposable {
  26400. /** Gets the list of active triggers */
  26401. static Triggers: {
  26402. [key: string]: number;
  26403. };
  26404. /** Gets the cursor to use when hovering items */
  26405. hoverCursor: string;
  26406. /** Gets the list of actions */
  26407. actions: IAction[];
  26408. /**
  26409. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26410. */
  26411. isRecursive: boolean;
  26412. /**
  26413. * Releases all associated resources
  26414. */
  26415. abstract dispose(): void;
  26416. /**
  26417. * Does this action manager has pointer triggers
  26418. */
  26419. abstract readonly hasPointerTriggers: boolean;
  26420. /**
  26421. * Does this action manager has pick triggers
  26422. */
  26423. abstract readonly hasPickTriggers: boolean;
  26424. /**
  26425. * Process a specific trigger
  26426. * @param trigger defines the trigger to process
  26427. * @param evt defines the event details to be processed
  26428. */
  26429. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26430. /**
  26431. * Does this action manager handles actions of any of the given triggers
  26432. * @param triggers defines the triggers to be tested
  26433. * @return a boolean indicating whether one (or more) of the triggers is handled
  26434. */
  26435. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26436. /**
  26437. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26438. * speed.
  26439. * @param triggerA defines the trigger to be tested
  26440. * @param triggerB defines the trigger to be tested
  26441. * @return a boolean indicating whether one (or more) of the triggers is handled
  26442. */
  26443. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26444. /**
  26445. * Does this action manager handles actions of a given trigger
  26446. * @param trigger defines the trigger to be tested
  26447. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26448. * @return whether the trigger is handled
  26449. */
  26450. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26451. /**
  26452. * Serialize this manager to a JSON object
  26453. * @param name defines the property name to store this manager
  26454. * @returns a JSON representation of this manager
  26455. */
  26456. abstract serialize(name: string): any;
  26457. /**
  26458. * Registers an action to this action manager
  26459. * @param action defines the action to be registered
  26460. * @return the action amended (prepared) after registration
  26461. */
  26462. abstract registerAction(action: IAction): Nullable<IAction>;
  26463. /**
  26464. * Unregisters an action to this action manager
  26465. * @param action defines the action to be unregistered
  26466. * @return a boolean indicating whether the action has been unregistered
  26467. */
  26468. abstract unregisterAction(action: IAction): Boolean;
  26469. /**
  26470. * Does exist one action manager with at least one trigger
  26471. **/
  26472. static readonly HasTriggers: boolean;
  26473. /**
  26474. * Does exist one action manager with at least one pick trigger
  26475. **/
  26476. static readonly HasPickTriggers: boolean;
  26477. /**
  26478. * Does exist one action manager that handles actions of a given trigger
  26479. * @param trigger defines the trigger to be tested
  26480. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26481. **/
  26482. static HasSpecificTrigger(trigger: number): boolean;
  26483. }
  26484. }
  26485. declare module BABYLON {
  26486. /**
  26487. * Defines how a node can be built from a string name.
  26488. */
  26489. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26490. /**
  26491. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26492. */
  26493. export class Node implements IBehaviorAware<Node> {
  26494. /** @hidden */
  26495. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26496. private static _NodeConstructors;
  26497. /**
  26498. * Add a new node constructor
  26499. * @param type defines the type name of the node to construct
  26500. * @param constructorFunc defines the constructor function
  26501. */
  26502. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26503. /**
  26504. * Returns a node constructor based on type name
  26505. * @param type defines the type name
  26506. * @param name defines the new node name
  26507. * @param scene defines the hosting scene
  26508. * @param options defines optional options to transmit to constructors
  26509. * @returns the new constructor or null
  26510. */
  26511. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26512. /**
  26513. * Gets or sets the name of the node
  26514. */
  26515. name: string;
  26516. /**
  26517. * Gets or sets the id of the node
  26518. */
  26519. id: string;
  26520. /**
  26521. * Gets or sets the unique id of the node
  26522. */
  26523. uniqueId: number;
  26524. /**
  26525. * Gets or sets a string used to store user defined state for the node
  26526. */
  26527. state: string;
  26528. /**
  26529. * Gets or sets an object used to store user defined information for the node
  26530. */
  26531. metadata: any;
  26532. /**
  26533. * For internal use only. Please do not use.
  26534. */
  26535. reservedDataStore: any;
  26536. /**
  26537. * List of inspectable custom properties (used by the Inspector)
  26538. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26539. */
  26540. inspectableCustomProperties: IInspectable[];
  26541. /**
  26542. * Gets or sets a boolean used to define if the node must be serialized
  26543. */
  26544. doNotSerialize: boolean;
  26545. /** @hidden */
  26546. _isDisposed: boolean;
  26547. /**
  26548. * Gets a list of Animations associated with the node
  26549. */
  26550. animations: Animation[];
  26551. protected _ranges: {
  26552. [name: string]: Nullable<AnimationRange>;
  26553. };
  26554. /**
  26555. * Callback raised when the node is ready to be used
  26556. */
  26557. onReady: Nullable<(node: Node) => void>;
  26558. private _isEnabled;
  26559. private _isParentEnabled;
  26560. private _isReady;
  26561. /** @hidden */
  26562. _currentRenderId: number;
  26563. private _parentUpdateId;
  26564. /** @hidden */
  26565. _childUpdateId: number;
  26566. /** @hidden */
  26567. _waitingParentId: Nullable<string>;
  26568. /** @hidden */
  26569. _scene: Scene;
  26570. /** @hidden */
  26571. _cache: any;
  26572. private _parentNode;
  26573. private _children;
  26574. /** @hidden */
  26575. _worldMatrix: Matrix;
  26576. /** @hidden */
  26577. _worldMatrixDeterminant: number;
  26578. /** @hidden */
  26579. _worldMatrixDeterminantIsDirty: boolean;
  26580. /** @hidden */
  26581. private _sceneRootNodesIndex;
  26582. /**
  26583. * Gets a boolean indicating if the node has been disposed
  26584. * @returns true if the node was disposed
  26585. */
  26586. isDisposed(): boolean;
  26587. /**
  26588. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26589. * @see https://doc.babylonjs.com/how_to/parenting
  26590. */
  26591. parent: Nullable<Node>;
  26592. private addToSceneRootNodes;
  26593. private removeFromSceneRootNodes;
  26594. private _animationPropertiesOverride;
  26595. /**
  26596. * Gets or sets the animation properties override
  26597. */
  26598. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26599. /**
  26600. * Gets a string idenfifying the name of the class
  26601. * @returns "Node" string
  26602. */
  26603. getClassName(): string;
  26604. /** @hidden */
  26605. readonly _isNode: boolean;
  26606. /**
  26607. * An event triggered when the mesh is disposed
  26608. */
  26609. onDisposeObservable: Observable<Node>;
  26610. private _onDisposeObserver;
  26611. /**
  26612. * Sets a callback that will be raised when the node will be disposed
  26613. */
  26614. onDispose: () => void;
  26615. /**
  26616. * Creates a new Node
  26617. * @param name the name and id to be given to this node
  26618. * @param scene the scene this node will be added to
  26619. * @param addToRootNodes the node will be added to scene.rootNodes
  26620. */
  26621. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26622. /**
  26623. * Gets the scene of the node
  26624. * @returns a scene
  26625. */
  26626. getScene(): Scene;
  26627. /**
  26628. * Gets the engine of the node
  26629. * @returns a Engine
  26630. */
  26631. getEngine(): Engine;
  26632. private _behaviors;
  26633. /**
  26634. * Attach a behavior to the node
  26635. * @see http://doc.babylonjs.com/features/behaviour
  26636. * @param behavior defines the behavior to attach
  26637. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26638. * @returns the current Node
  26639. */
  26640. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26641. /**
  26642. * Remove an attached behavior
  26643. * @see http://doc.babylonjs.com/features/behaviour
  26644. * @param behavior defines the behavior to attach
  26645. * @returns the current Node
  26646. */
  26647. removeBehavior(behavior: Behavior<Node>): Node;
  26648. /**
  26649. * Gets the list of attached behaviors
  26650. * @see http://doc.babylonjs.com/features/behaviour
  26651. */
  26652. readonly behaviors: Behavior<Node>[];
  26653. /**
  26654. * Gets an attached behavior by name
  26655. * @param name defines the name of the behavior to look for
  26656. * @see http://doc.babylonjs.com/features/behaviour
  26657. * @returns null if behavior was not found else the requested behavior
  26658. */
  26659. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26660. /**
  26661. * Returns the latest update of the World matrix
  26662. * @returns a Matrix
  26663. */
  26664. getWorldMatrix(): Matrix;
  26665. /** @hidden */
  26666. _getWorldMatrixDeterminant(): number;
  26667. /**
  26668. * Returns directly the latest state of the mesh World matrix.
  26669. * A Matrix is returned.
  26670. */
  26671. readonly worldMatrixFromCache: Matrix;
  26672. /** @hidden */
  26673. _initCache(): void;
  26674. /** @hidden */
  26675. updateCache(force?: boolean): void;
  26676. /** @hidden */
  26677. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26678. /** @hidden */
  26679. _updateCache(ignoreParentClass?: boolean): void;
  26680. /** @hidden */
  26681. _isSynchronized(): boolean;
  26682. /** @hidden */
  26683. _markSyncedWithParent(): void;
  26684. /** @hidden */
  26685. isSynchronizedWithParent(): boolean;
  26686. /** @hidden */
  26687. isSynchronized(): boolean;
  26688. /**
  26689. * Is this node ready to be used/rendered
  26690. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26691. * @return true if the node is ready
  26692. */
  26693. isReady(completeCheck?: boolean): boolean;
  26694. /**
  26695. * Is this node enabled?
  26696. * 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
  26697. * @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
  26698. * @return whether this node (and its parent) is enabled
  26699. */
  26700. isEnabled(checkAncestors?: boolean): boolean;
  26701. /** @hidden */
  26702. protected _syncParentEnabledState(): void;
  26703. /**
  26704. * Set the enabled state of this node
  26705. * @param value defines the new enabled state
  26706. */
  26707. setEnabled(value: boolean): void;
  26708. /**
  26709. * Is this node a descendant of the given node?
  26710. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26711. * @param ancestor defines the parent node to inspect
  26712. * @returns a boolean indicating if this node is a descendant of the given node
  26713. */
  26714. isDescendantOf(ancestor: Node): boolean;
  26715. /** @hidden */
  26716. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26717. /**
  26718. * Will return all nodes that have this node as ascendant
  26719. * @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
  26720. * @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
  26721. * @return all children nodes of all types
  26722. */
  26723. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26724. /**
  26725. * Get all child-meshes of this node
  26726. * @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)
  26727. * @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
  26728. * @returns an array of AbstractMesh
  26729. */
  26730. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26731. /**
  26732. * Get all direct children of this node
  26733. * @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
  26734. * @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)
  26735. * @returns an array of Node
  26736. */
  26737. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26738. /** @hidden */
  26739. _setReady(state: boolean): void;
  26740. /**
  26741. * Get an animation by name
  26742. * @param name defines the name of the animation to look for
  26743. * @returns null if not found else the requested animation
  26744. */
  26745. getAnimationByName(name: string): Nullable<Animation>;
  26746. /**
  26747. * Creates an animation range for this node
  26748. * @param name defines the name of the range
  26749. * @param from defines the starting key
  26750. * @param to defines the end key
  26751. */
  26752. createAnimationRange(name: string, from: number, to: number): void;
  26753. /**
  26754. * Delete a specific animation range
  26755. * @param name defines the name of the range to delete
  26756. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26757. */
  26758. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26759. /**
  26760. * Get an animation range by name
  26761. * @param name defines the name of the animation range to look for
  26762. * @returns null if not found else the requested animation range
  26763. */
  26764. getAnimationRange(name: string): Nullable<AnimationRange>;
  26765. /**
  26766. * Gets the list of all animation ranges defined on this node
  26767. * @returns an array
  26768. */
  26769. getAnimationRanges(): Nullable<AnimationRange>[];
  26770. /**
  26771. * Will start the animation sequence
  26772. * @param name defines the range frames for animation sequence
  26773. * @param loop defines if the animation should loop (false by default)
  26774. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26775. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26776. * @returns the object created for this animation. If range does not exist, it will return null
  26777. */
  26778. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26779. /**
  26780. * Serialize animation ranges into a JSON compatible object
  26781. * @returns serialization object
  26782. */
  26783. serializeAnimationRanges(): any;
  26784. /**
  26785. * Computes the world matrix of the node
  26786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26787. * @returns the world matrix
  26788. */
  26789. computeWorldMatrix(force?: boolean): Matrix;
  26790. /**
  26791. * Releases resources associated with this node.
  26792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26794. */
  26795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26796. /**
  26797. * Parse animation range data from a serialization object and store them into a given node
  26798. * @param node defines where to store the animation ranges
  26799. * @param parsedNode defines the serialization object to read data from
  26800. * @param scene defines the hosting scene
  26801. */
  26802. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26803. /**
  26804. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26805. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26806. * @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
  26807. * @returns the new bounding vectors
  26808. */
  26809. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26810. min: Vector3;
  26811. max: Vector3;
  26812. };
  26813. }
  26814. }
  26815. declare module BABYLON {
  26816. /**
  26817. * @hidden
  26818. */
  26819. export class _IAnimationState {
  26820. key: number;
  26821. repeatCount: number;
  26822. workValue?: any;
  26823. loopMode?: number;
  26824. offsetValue?: any;
  26825. highLimitValue?: any;
  26826. }
  26827. /**
  26828. * Class used to store any kind of animation
  26829. */
  26830. export class Animation {
  26831. /**Name of the animation */
  26832. name: string;
  26833. /**Property to animate */
  26834. targetProperty: string;
  26835. /**The frames per second of the animation */
  26836. framePerSecond: number;
  26837. /**The data type of the animation */
  26838. dataType: number;
  26839. /**The loop mode of the animation */
  26840. loopMode?: number | undefined;
  26841. /**Specifies if blending should be enabled */
  26842. enableBlending?: boolean | undefined;
  26843. /**
  26844. * Use matrix interpolation instead of using direct key value when animating matrices
  26845. */
  26846. static AllowMatricesInterpolation: boolean;
  26847. /**
  26848. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26849. */
  26850. static AllowMatrixDecomposeForInterpolation: boolean;
  26851. /**
  26852. * Stores the key frames of the animation
  26853. */
  26854. private _keys;
  26855. /**
  26856. * Stores the easing function of the animation
  26857. */
  26858. private _easingFunction;
  26859. /**
  26860. * @hidden Internal use only
  26861. */
  26862. _runtimeAnimations: RuntimeAnimation[];
  26863. /**
  26864. * The set of event that will be linked to this animation
  26865. */
  26866. private _events;
  26867. /**
  26868. * Stores an array of target property paths
  26869. */
  26870. targetPropertyPath: string[];
  26871. /**
  26872. * Stores the blending speed of the animation
  26873. */
  26874. blendingSpeed: number;
  26875. /**
  26876. * Stores the animation ranges for the animation
  26877. */
  26878. private _ranges;
  26879. /**
  26880. * @hidden Internal use
  26881. */
  26882. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26883. /**
  26884. * Sets up an animation
  26885. * @param property The property to animate
  26886. * @param animationType The animation type to apply
  26887. * @param framePerSecond The frames per second of the animation
  26888. * @param easingFunction The easing function used in the animation
  26889. * @returns The created animation
  26890. */
  26891. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26892. /**
  26893. * Create and start an animation on a node
  26894. * @param name defines the name of the global animation that will be run on all nodes
  26895. * @param node defines the root node where the animation will take place
  26896. * @param targetProperty defines property to animate
  26897. * @param framePerSecond defines the number of frame per second yo use
  26898. * @param totalFrame defines the number of frames in total
  26899. * @param from defines the initial value
  26900. * @param to defines the final value
  26901. * @param loopMode defines which loop mode you want to use (off by default)
  26902. * @param easingFunction defines the easing function to use (linear by default)
  26903. * @param onAnimationEnd defines the callback to call when animation end
  26904. * @returns the animatable created for this animation
  26905. */
  26906. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26907. /**
  26908. * Create and start an animation on a node and its descendants
  26909. * @param name defines the name of the global animation that will be run on all nodes
  26910. * @param node defines the root node where the animation will take place
  26911. * @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
  26912. * @param targetProperty defines property to animate
  26913. * @param framePerSecond defines the number of frame per second to use
  26914. * @param totalFrame defines the number of frames in total
  26915. * @param from defines the initial value
  26916. * @param to defines the final value
  26917. * @param loopMode defines which loop mode you want to use (off by default)
  26918. * @param easingFunction defines the easing function to use (linear by default)
  26919. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26920. * @returns the list of animatables created for all nodes
  26921. * @example https://www.babylonjs-playground.com/#MH0VLI
  26922. */
  26923. 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[]>;
  26924. /**
  26925. * Creates a new animation, merges it with the existing animations and starts it
  26926. * @param name Name of the animation
  26927. * @param node Node which contains the scene that begins the animations
  26928. * @param targetProperty Specifies which property to animate
  26929. * @param framePerSecond The frames per second of the animation
  26930. * @param totalFrame The total number of frames
  26931. * @param from The frame at the beginning of the animation
  26932. * @param to The frame at the end of the animation
  26933. * @param loopMode Specifies the loop mode of the animation
  26934. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26935. * @param onAnimationEnd Callback to run once the animation is complete
  26936. * @returns Nullable animation
  26937. */
  26938. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26939. /**
  26940. * Transition property of an host to the target Value
  26941. * @param property The property to transition
  26942. * @param targetValue The target Value of the property
  26943. * @param host The object where the property to animate belongs
  26944. * @param scene Scene used to run the animation
  26945. * @param frameRate Framerate (in frame/s) to use
  26946. * @param transition The transition type we want to use
  26947. * @param duration The duration of the animation, in milliseconds
  26948. * @param onAnimationEnd Callback trigger at the end of the animation
  26949. * @returns Nullable animation
  26950. */
  26951. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26952. /**
  26953. * Return the array of runtime animations currently using this animation
  26954. */
  26955. readonly runtimeAnimations: RuntimeAnimation[];
  26956. /**
  26957. * Specifies if any of the runtime animations are currently running
  26958. */
  26959. readonly hasRunningRuntimeAnimations: boolean;
  26960. /**
  26961. * Initializes the animation
  26962. * @param name Name of the animation
  26963. * @param targetProperty Property to animate
  26964. * @param framePerSecond The frames per second of the animation
  26965. * @param dataType The data type of the animation
  26966. * @param loopMode The loop mode of the animation
  26967. * @param enableBlending Specifies if blending should be enabled
  26968. */
  26969. constructor(
  26970. /**Name of the animation */
  26971. name: string,
  26972. /**Property to animate */
  26973. targetProperty: string,
  26974. /**The frames per second of the animation */
  26975. framePerSecond: number,
  26976. /**The data type of the animation */
  26977. dataType: number,
  26978. /**The loop mode of the animation */
  26979. loopMode?: number | undefined,
  26980. /**Specifies if blending should be enabled */
  26981. enableBlending?: boolean | undefined);
  26982. /**
  26983. * Converts the animation to a string
  26984. * @param fullDetails support for multiple levels of logging within scene loading
  26985. * @returns String form of the animation
  26986. */
  26987. toString(fullDetails?: boolean): string;
  26988. /**
  26989. * Add an event to this animation
  26990. * @param event Event to add
  26991. */
  26992. addEvent(event: AnimationEvent): void;
  26993. /**
  26994. * Remove all events found at the given frame
  26995. * @param frame The frame to remove events from
  26996. */
  26997. removeEvents(frame: number): void;
  26998. /**
  26999. * Retrieves all the events from the animation
  27000. * @returns Events from the animation
  27001. */
  27002. getEvents(): AnimationEvent[];
  27003. /**
  27004. * Creates an animation range
  27005. * @param name Name of the animation range
  27006. * @param from Starting frame of the animation range
  27007. * @param to Ending frame of the animation
  27008. */
  27009. createRange(name: string, from: number, to: number): void;
  27010. /**
  27011. * Deletes an animation range by name
  27012. * @param name Name of the animation range to delete
  27013. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27014. */
  27015. deleteRange(name: string, deleteFrames?: boolean): void;
  27016. /**
  27017. * Gets the animation range by name, or null if not defined
  27018. * @param name Name of the animation range
  27019. * @returns Nullable animation range
  27020. */
  27021. getRange(name: string): Nullable<AnimationRange>;
  27022. /**
  27023. * Gets the key frames from the animation
  27024. * @returns The key frames of the animation
  27025. */
  27026. getKeys(): Array<IAnimationKey>;
  27027. /**
  27028. * Gets the highest frame rate of the animation
  27029. * @returns Highest frame rate of the animation
  27030. */
  27031. getHighestFrame(): number;
  27032. /**
  27033. * Gets the easing function of the animation
  27034. * @returns Easing function of the animation
  27035. */
  27036. getEasingFunction(): IEasingFunction;
  27037. /**
  27038. * Sets the easing function of the animation
  27039. * @param easingFunction A custom mathematical formula for animation
  27040. */
  27041. setEasingFunction(easingFunction: EasingFunction): void;
  27042. /**
  27043. * Interpolates a scalar linearly
  27044. * @param startValue Start value of the animation curve
  27045. * @param endValue End value of the animation curve
  27046. * @param gradient Scalar amount to interpolate
  27047. * @returns Interpolated scalar value
  27048. */
  27049. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27050. /**
  27051. * Interpolates a scalar cubically
  27052. * @param startValue Start value of the animation curve
  27053. * @param outTangent End tangent of the animation
  27054. * @param endValue End value of the animation curve
  27055. * @param inTangent Start tangent of the animation curve
  27056. * @param gradient Scalar amount to interpolate
  27057. * @returns Interpolated scalar value
  27058. */
  27059. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27060. /**
  27061. * Interpolates a quaternion using a spherical linear interpolation
  27062. * @param startValue Start value of the animation curve
  27063. * @param endValue End value of the animation curve
  27064. * @param gradient Scalar amount to interpolate
  27065. * @returns Interpolated quaternion value
  27066. */
  27067. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27068. /**
  27069. * Interpolates a quaternion cubically
  27070. * @param startValue Start value of the animation curve
  27071. * @param outTangent End tangent of the animation curve
  27072. * @param endValue End value of the animation curve
  27073. * @param inTangent Start tangent of the animation curve
  27074. * @param gradient Scalar amount to interpolate
  27075. * @returns Interpolated quaternion value
  27076. */
  27077. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27078. /**
  27079. * Interpolates a Vector3 linearl
  27080. * @param startValue Start value of the animation curve
  27081. * @param endValue End value of the animation curve
  27082. * @param gradient Scalar amount to interpolate
  27083. * @returns Interpolated scalar value
  27084. */
  27085. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27086. /**
  27087. * Interpolates a Vector3 cubically
  27088. * @param startValue Start value of the animation curve
  27089. * @param outTangent End tangent of the animation
  27090. * @param endValue End value of the animation curve
  27091. * @param inTangent Start tangent of the animation curve
  27092. * @param gradient Scalar amount to interpolate
  27093. * @returns InterpolatedVector3 value
  27094. */
  27095. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27096. /**
  27097. * Interpolates a Vector2 linearly
  27098. * @param startValue Start value of the animation curve
  27099. * @param endValue End value of the animation curve
  27100. * @param gradient Scalar amount to interpolate
  27101. * @returns Interpolated Vector2 value
  27102. */
  27103. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27104. /**
  27105. * Interpolates a Vector2 cubically
  27106. * @param startValue Start value of the animation curve
  27107. * @param outTangent End tangent of the animation
  27108. * @param endValue End value of the animation curve
  27109. * @param inTangent Start tangent of the animation curve
  27110. * @param gradient Scalar amount to interpolate
  27111. * @returns Interpolated Vector2 value
  27112. */
  27113. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27114. /**
  27115. * Interpolates a size linearly
  27116. * @param startValue Start value of the animation curve
  27117. * @param endValue End value of the animation curve
  27118. * @param gradient Scalar amount to interpolate
  27119. * @returns Interpolated Size value
  27120. */
  27121. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27122. /**
  27123. * Interpolates a Color3 linearly
  27124. * @param startValue Start value of the animation curve
  27125. * @param endValue End value of the animation curve
  27126. * @param gradient Scalar amount to interpolate
  27127. * @returns Interpolated Color3 value
  27128. */
  27129. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27130. /**
  27131. * @hidden Internal use only
  27132. */
  27133. _getKeyValue(value: any): any;
  27134. /**
  27135. * @hidden Internal use only
  27136. */
  27137. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27138. /**
  27139. * Defines the function to use to interpolate matrices
  27140. * @param startValue defines the start matrix
  27141. * @param endValue defines the end matrix
  27142. * @param gradient defines the gradient between both matrices
  27143. * @param result defines an optional target matrix where to store the interpolation
  27144. * @returns the interpolated matrix
  27145. */
  27146. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27147. /**
  27148. * Makes a copy of the animation
  27149. * @returns Cloned animation
  27150. */
  27151. clone(): Animation;
  27152. /**
  27153. * Sets the key frames of the animation
  27154. * @param values The animation key frames to set
  27155. */
  27156. setKeys(values: Array<IAnimationKey>): void;
  27157. /**
  27158. * Serializes the animation to an object
  27159. * @returns Serialized object
  27160. */
  27161. serialize(): any;
  27162. /**
  27163. * Float animation type
  27164. */
  27165. private static _ANIMATIONTYPE_FLOAT;
  27166. /**
  27167. * Vector3 animation type
  27168. */
  27169. private static _ANIMATIONTYPE_VECTOR3;
  27170. /**
  27171. * Quaternion animation type
  27172. */
  27173. private static _ANIMATIONTYPE_QUATERNION;
  27174. /**
  27175. * Matrix animation type
  27176. */
  27177. private static _ANIMATIONTYPE_MATRIX;
  27178. /**
  27179. * Color3 animation type
  27180. */
  27181. private static _ANIMATIONTYPE_COLOR3;
  27182. /**
  27183. * Vector2 animation type
  27184. */
  27185. private static _ANIMATIONTYPE_VECTOR2;
  27186. /**
  27187. * Size animation type
  27188. */
  27189. private static _ANIMATIONTYPE_SIZE;
  27190. /**
  27191. * Relative Loop Mode
  27192. */
  27193. private static _ANIMATIONLOOPMODE_RELATIVE;
  27194. /**
  27195. * Cycle Loop Mode
  27196. */
  27197. private static _ANIMATIONLOOPMODE_CYCLE;
  27198. /**
  27199. * Constant Loop Mode
  27200. */
  27201. private static _ANIMATIONLOOPMODE_CONSTANT;
  27202. /**
  27203. * Get the float animation type
  27204. */
  27205. static readonly ANIMATIONTYPE_FLOAT: number;
  27206. /**
  27207. * Get the Vector3 animation type
  27208. */
  27209. static readonly ANIMATIONTYPE_VECTOR3: number;
  27210. /**
  27211. * Get the Vector2 animation type
  27212. */
  27213. static readonly ANIMATIONTYPE_VECTOR2: number;
  27214. /**
  27215. * Get the Size animation type
  27216. */
  27217. static readonly ANIMATIONTYPE_SIZE: number;
  27218. /**
  27219. * Get the Quaternion animation type
  27220. */
  27221. static readonly ANIMATIONTYPE_QUATERNION: number;
  27222. /**
  27223. * Get the Matrix animation type
  27224. */
  27225. static readonly ANIMATIONTYPE_MATRIX: number;
  27226. /**
  27227. * Get the Color3 animation type
  27228. */
  27229. static readonly ANIMATIONTYPE_COLOR3: number;
  27230. /**
  27231. * Get the Relative Loop Mode
  27232. */
  27233. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27234. /**
  27235. * Get the Cycle Loop Mode
  27236. */
  27237. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27238. /**
  27239. * Get the Constant Loop Mode
  27240. */
  27241. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27242. /** @hidden */
  27243. static _UniversalLerp(left: any, right: any, amount: number): any;
  27244. /**
  27245. * Parses an animation object and creates an animation
  27246. * @param parsedAnimation Parsed animation object
  27247. * @returns Animation object
  27248. */
  27249. static Parse(parsedAnimation: any): Animation;
  27250. /**
  27251. * Appends the serialized animations from the source animations
  27252. * @param source Source containing the animations
  27253. * @param destination Target to store the animations
  27254. */
  27255. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27256. }
  27257. }
  27258. declare module BABYLON {
  27259. /**
  27260. * Interface containing an array of animations
  27261. */
  27262. export interface IAnimatable {
  27263. /**
  27264. * Array of animations
  27265. */
  27266. animations: Nullable<Array<Animation>>;
  27267. }
  27268. }
  27269. declare module BABYLON {
  27270. /**
  27271. * This represents all the required information to add a fresnel effect on a material:
  27272. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27273. */
  27274. export class FresnelParameters {
  27275. private _isEnabled;
  27276. /**
  27277. * Define if the fresnel effect is enable or not.
  27278. */
  27279. isEnabled: boolean;
  27280. /**
  27281. * Define the color used on edges (grazing angle)
  27282. */
  27283. leftColor: Color3;
  27284. /**
  27285. * Define the color used on center
  27286. */
  27287. rightColor: Color3;
  27288. /**
  27289. * Define bias applied to computed fresnel term
  27290. */
  27291. bias: number;
  27292. /**
  27293. * Defined the power exponent applied to fresnel term
  27294. */
  27295. power: number;
  27296. /**
  27297. * Clones the current fresnel and its valuues
  27298. * @returns a clone fresnel configuration
  27299. */
  27300. clone(): FresnelParameters;
  27301. /**
  27302. * Serializes the current fresnel parameters to a JSON representation.
  27303. * @return the JSON serialization
  27304. */
  27305. serialize(): any;
  27306. /**
  27307. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27308. * @param parsedFresnelParameters Define the JSON representation
  27309. * @returns the parsed parameters
  27310. */
  27311. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27312. }
  27313. }
  27314. declare module BABYLON {
  27315. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27316. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27317. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27318. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27319. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27320. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27321. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27322. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27323. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27324. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27325. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27326. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27327. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27328. /**
  27329. * Decorator used to define property that can be serialized as reference to a camera
  27330. * @param sourceName defines the name of the property to decorate
  27331. */
  27332. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27333. /**
  27334. * Class used to help serialization objects
  27335. */
  27336. export class SerializationHelper {
  27337. /** @hidden */
  27338. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27339. /** @hidden */
  27340. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27341. /** @hidden */
  27342. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27343. /** @hidden */
  27344. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27345. /**
  27346. * Appends the serialized animations from the source animations
  27347. * @param source Source containing the animations
  27348. * @param destination Target to store the animations
  27349. */
  27350. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27351. /**
  27352. * Static function used to serialized a specific entity
  27353. * @param entity defines the entity to serialize
  27354. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27355. * @returns a JSON compatible object representing the serialization of the entity
  27356. */
  27357. static Serialize<T>(entity: T, serializationObject?: any): any;
  27358. /**
  27359. * Creates a new entity from a serialization data object
  27360. * @param creationFunction defines a function used to instanciated the new entity
  27361. * @param source defines the source serialization data
  27362. * @param scene defines the hosting scene
  27363. * @param rootUrl defines the root url for resources
  27364. * @returns a new entity
  27365. */
  27366. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27367. /**
  27368. * Clones an object
  27369. * @param creationFunction defines the function used to instanciate the new object
  27370. * @param source defines the source object
  27371. * @returns the cloned object
  27372. */
  27373. static Clone<T>(creationFunction: () => T, source: T): T;
  27374. /**
  27375. * Instanciates a new object based on a source one (some data will be shared between both object)
  27376. * @param creationFunction defines the function used to instanciate the new object
  27377. * @param source defines the source object
  27378. * @returns the new object
  27379. */
  27380. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27381. }
  27382. }
  27383. declare module BABYLON {
  27384. /**
  27385. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27386. */
  27387. export interface CubeMapInfo {
  27388. /**
  27389. * The pixel array for the front face.
  27390. * This is stored in format, left to right, up to down format.
  27391. */
  27392. front: Nullable<ArrayBufferView>;
  27393. /**
  27394. * The pixel array for the back face.
  27395. * This is stored in format, left to right, up to down format.
  27396. */
  27397. back: Nullable<ArrayBufferView>;
  27398. /**
  27399. * The pixel array for the left face.
  27400. * This is stored in format, left to right, up to down format.
  27401. */
  27402. left: Nullable<ArrayBufferView>;
  27403. /**
  27404. * The pixel array for the right face.
  27405. * This is stored in format, left to right, up to down format.
  27406. */
  27407. right: Nullable<ArrayBufferView>;
  27408. /**
  27409. * The pixel array for the up face.
  27410. * This is stored in format, left to right, up to down format.
  27411. */
  27412. up: Nullable<ArrayBufferView>;
  27413. /**
  27414. * The pixel array for the down face.
  27415. * This is stored in format, left to right, up to down format.
  27416. */
  27417. down: Nullable<ArrayBufferView>;
  27418. /**
  27419. * The size of the cubemap stored.
  27420. *
  27421. * Each faces will be size * size pixels.
  27422. */
  27423. size: number;
  27424. /**
  27425. * The format of the texture.
  27426. *
  27427. * RGBA, RGB.
  27428. */
  27429. format: number;
  27430. /**
  27431. * The type of the texture data.
  27432. *
  27433. * UNSIGNED_INT, FLOAT.
  27434. */
  27435. type: number;
  27436. /**
  27437. * Specifies whether the texture is in gamma space.
  27438. */
  27439. gammaSpace: boolean;
  27440. }
  27441. /**
  27442. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27443. */
  27444. export class PanoramaToCubeMapTools {
  27445. private static FACE_FRONT;
  27446. private static FACE_BACK;
  27447. private static FACE_RIGHT;
  27448. private static FACE_LEFT;
  27449. private static FACE_DOWN;
  27450. private static FACE_UP;
  27451. /**
  27452. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27453. *
  27454. * @param float32Array The source data.
  27455. * @param inputWidth The width of the input panorama.
  27456. * @param inputHeight The height of the input panorama.
  27457. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27458. * @return The cubemap data
  27459. */
  27460. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27461. private static CreateCubemapTexture;
  27462. private static CalcProjectionSpherical;
  27463. }
  27464. }
  27465. declare module BABYLON {
  27466. /**
  27467. * Helper class dealing with the extraction of spherical polynomial dataArray
  27468. * from a cube map.
  27469. */
  27470. export class CubeMapToSphericalPolynomialTools {
  27471. private static FileFaces;
  27472. /**
  27473. * Converts a texture to the according Spherical Polynomial data.
  27474. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27475. *
  27476. * @param texture The texture to extract the information from.
  27477. * @return The Spherical Polynomial data.
  27478. */
  27479. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27480. /**
  27481. * Converts a cubemap to the according Spherical Polynomial data.
  27482. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27483. *
  27484. * @param cubeInfo The Cube map to extract the information from.
  27485. * @return The Spherical Polynomial data.
  27486. */
  27487. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27488. }
  27489. }
  27490. declare module BABYLON {
  27491. /**
  27492. * Class used to manipulate GUIDs
  27493. */
  27494. export class GUID {
  27495. /**
  27496. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27497. * Be aware Math.random() could cause collisions, but:
  27498. * "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"
  27499. * @returns a pseudo random id
  27500. */
  27501. static RandomId(): string;
  27502. }
  27503. }
  27504. declare module BABYLON {
  27505. /**
  27506. * Base class of all the textures in babylon.
  27507. * It groups all the common properties the materials, post process, lights... might need
  27508. * in order to make a correct use of the texture.
  27509. */
  27510. export class BaseTexture implements IAnimatable {
  27511. /**
  27512. * Default anisotropic filtering level for the application.
  27513. * It is set to 4 as a good tradeoff between perf and quality.
  27514. */
  27515. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27516. /**
  27517. * Gets or sets the unique id of the texture
  27518. */
  27519. uniqueId: number;
  27520. /**
  27521. * Define the name of the texture.
  27522. */
  27523. name: string;
  27524. /**
  27525. * Gets or sets an object used to store user defined information.
  27526. */
  27527. metadata: any;
  27528. /**
  27529. * For internal use only. Please do not use.
  27530. */
  27531. reservedDataStore: any;
  27532. private _hasAlpha;
  27533. /**
  27534. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27535. */
  27536. hasAlpha: boolean;
  27537. /**
  27538. * Defines if the alpha value should be determined via the rgb values.
  27539. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27540. */
  27541. getAlphaFromRGB: boolean;
  27542. /**
  27543. * Intensity or strength of the texture.
  27544. * It is commonly used by materials to fine tune the intensity of the texture
  27545. */
  27546. level: number;
  27547. /**
  27548. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27549. * This is part of the texture as textures usually maps to one uv set.
  27550. */
  27551. coordinatesIndex: number;
  27552. private _coordinatesMode;
  27553. /**
  27554. * How a texture is mapped.
  27555. *
  27556. * | Value | Type | Description |
  27557. * | ----- | ----------------------------------- | ----------- |
  27558. * | 0 | EXPLICIT_MODE | |
  27559. * | 1 | SPHERICAL_MODE | |
  27560. * | 2 | PLANAR_MODE | |
  27561. * | 3 | CUBIC_MODE | |
  27562. * | 4 | PROJECTION_MODE | |
  27563. * | 5 | SKYBOX_MODE | |
  27564. * | 6 | INVCUBIC_MODE | |
  27565. * | 7 | EQUIRECTANGULAR_MODE | |
  27566. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27567. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27568. */
  27569. coordinatesMode: number;
  27570. /**
  27571. * | Value | Type | Description |
  27572. * | ----- | ------------------ | ----------- |
  27573. * | 0 | CLAMP_ADDRESSMODE | |
  27574. * | 1 | WRAP_ADDRESSMODE | |
  27575. * | 2 | MIRROR_ADDRESSMODE | |
  27576. */
  27577. wrapU: number;
  27578. /**
  27579. * | Value | Type | Description |
  27580. * | ----- | ------------------ | ----------- |
  27581. * | 0 | CLAMP_ADDRESSMODE | |
  27582. * | 1 | WRAP_ADDRESSMODE | |
  27583. * | 2 | MIRROR_ADDRESSMODE | |
  27584. */
  27585. wrapV: number;
  27586. /**
  27587. * | Value | Type | Description |
  27588. * | ----- | ------------------ | ----------- |
  27589. * | 0 | CLAMP_ADDRESSMODE | |
  27590. * | 1 | WRAP_ADDRESSMODE | |
  27591. * | 2 | MIRROR_ADDRESSMODE | |
  27592. */
  27593. wrapR: number;
  27594. /**
  27595. * With compliant hardware and browser (supporting anisotropic filtering)
  27596. * this defines the level of anisotropic filtering in the texture.
  27597. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27598. */
  27599. anisotropicFilteringLevel: number;
  27600. /**
  27601. * Define if the texture is a cube texture or if false a 2d texture.
  27602. */
  27603. isCube: boolean;
  27604. /**
  27605. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27606. */
  27607. is3D: boolean;
  27608. /**
  27609. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27610. * HDR texture are usually stored in linear space.
  27611. * This only impacts the PBR and Background materials
  27612. */
  27613. gammaSpace: boolean;
  27614. /**
  27615. * Gets whether or not the texture contains RGBD data.
  27616. */
  27617. readonly isRGBD: boolean;
  27618. /**
  27619. * Is Z inverted in the texture (useful in a cube texture).
  27620. */
  27621. invertZ: boolean;
  27622. /**
  27623. * Are mip maps generated for this texture or not.
  27624. */
  27625. readonly noMipmap: boolean;
  27626. /**
  27627. * @hidden
  27628. */
  27629. lodLevelInAlpha: boolean;
  27630. /**
  27631. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27632. */
  27633. lodGenerationOffset: number;
  27634. /**
  27635. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27636. */
  27637. lodGenerationScale: number;
  27638. /**
  27639. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27640. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27641. * average roughness values.
  27642. */
  27643. linearSpecularLOD: boolean;
  27644. /**
  27645. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27646. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27647. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27648. */
  27649. irradianceTexture: Nullable<BaseTexture>;
  27650. /**
  27651. * Define if the texture is a render target.
  27652. */
  27653. isRenderTarget: boolean;
  27654. /**
  27655. * Define the unique id of the texture in the scene.
  27656. */
  27657. readonly uid: string;
  27658. /**
  27659. * Return a string representation of the texture.
  27660. * @returns the texture as a string
  27661. */
  27662. toString(): string;
  27663. /**
  27664. * Get the class name of the texture.
  27665. * @returns "BaseTexture"
  27666. */
  27667. getClassName(): string;
  27668. /**
  27669. * Define the list of animation attached to the texture.
  27670. */
  27671. animations: Animation[];
  27672. /**
  27673. * An event triggered when the texture is disposed.
  27674. */
  27675. onDisposeObservable: Observable<BaseTexture>;
  27676. private _onDisposeObserver;
  27677. /**
  27678. * Callback triggered when the texture has been disposed.
  27679. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27680. */
  27681. onDispose: () => void;
  27682. /**
  27683. * Define the current state of the loading sequence when in delayed load mode.
  27684. */
  27685. delayLoadState: number;
  27686. private _scene;
  27687. /** @hidden */
  27688. _texture: Nullable<InternalTexture>;
  27689. private _uid;
  27690. /**
  27691. * Define if the texture is preventinga material to render or not.
  27692. * If not and the texture is not ready, the engine will use a default black texture instead.
  27693. */
  27694. readonly isBlocking: boolean;
  27695. /**
  27696. * Instantiates a new BaseTexture.
  27697. * Base class of all the textures in babylon.
  27698. * It groups all the common properties the materials, post process, lights... might need
  27699. * in order to make a correct use of the texture.
  27700. * @param scene Define the scene the texture blongs to
  27701. */
  27702. constructor(scene: Nullable<Scene>);
  27703. /**
  27704. * Get the scene the texture belongs to.
  27705. * @returns the scene or null if undefined
  27706. */
  27707. getScene(): Nullable<Scene>;
  27708. /**
  27709. * Get the texture transform matrix used to offset tile the texture for istance.
  27710. * @returns the transformation matrix
  27711. */
  27712. getTextureMatrix(): Matrix;
  27713. /**
  27714. * Get the texture reflection matrix used to rotate/transform the reflection.
  27715. * @returns the reflection matrix
  27716. */
  27717. getReflectionTextureMatrix(): Matrix;
  27718. /**
  27719. * Get the underlying lower level texture from Babylon.
  27720. * @returns the insternal texture
  27721. */
  27722. getInternalTexture(): Nullable<InternalTexture>;
  27723. /**
  27724. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27725. * @returns true if ready or not blocking
  27726. */
  27727. isReadyOrNotBlocking(): boolean;
  27728. /**
  27729. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27730. * @returns true if fully ready
  27731. */
  27732. isReady(): boolean;
  27733. private _cachedSize;
  27734. /**
  27735. * Get the size of the texture.
  27736. * @returns the texture size.
  27737. */
  27738. getSize(): ISize;
  27739. /**
  27740. * Get the base size of the texture.
  27741. * It can be different from the size if the texture has been resized for POT for instance
  27742. * @returns the base size
  27743. */
  27744. getBaseSize(): ISize;
  27745. /**
  27746. * Update the sampling mode of the texture.
  27747. * Default is Trilinear mode.
  27748. *
  27749. * | Value | Type | Description |
  27750. * | ----- | ------------------ | ----------- |
  27751. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27752. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27753. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27754. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27755. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27756. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27757. * | 7 | NEAREST_LINEAR | |
  27758. * | 8 | NEAREST_NEAREST | |
  27759. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27760. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27761. * | 11 | LINEAR_LINEAR | |
  27762. * | 12 | LINEAR_NEAREST | |
  27763. *
  27764. * > _mag_: magnification filter (close to the viewer)
  27765. * > _min_: minification filter (far from the viewer)
  27766. * > _mip_: filter used between mip map levels
  27767. *@param samplingMode Define the new sampling mode of the texture
  27768. */
  27769. updateSamplingMode(samplingMode: number): void;
  27770. /**
  27771. * Scales the texture if is `canRescale()`
  27772. * @param ratio the resize factor we want to use to rescale
  27773. */
  27774. scale(ratio: number): void;
  27775. /**
  27776. * Get if the texture can rescale.
  27777. */
  27778. readonly canRescale: boolean;
  27779. /** @hidden */
  27780. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27781. /** @hidden */
  27782. _rebuild(): void;
  27783. /**
  27784. * Triggers the load sequence in delayed load mode.
  27785. */
  27786. delayLoad(): void;
  27787. /**
  27788. * Clones the texture.
  27789. * @returns the cloned texture
  27790. */
  27791. clone(): Nullable<BaseTexture>;
  27792. /**
  27793. * Get the texture underlying type (INT, FLOAT...)
  27794. */
  27795. readonly textureType: number;
  27796. /**
  27797. * Get the texture underlying format (RGB, RGBA...)
  27798. */
  27799. readonly textureFormat: number;
  27800. /**
  27801. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27802. * This will returns an RGBA array buffer containing either in values (0-255) or
  27803. * float values (0-1) depending of the underlying buffer type.
  27804. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27805. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27806. * @param buffer defines a user defined buffer to fill with data (can be null)
  27807. * @returns The Array buffer containing the pixels data.
  27808. */
  27809. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27810. /**
  27811. * Release and destroy the underlying lower level texture aka internalTexture.
  27812. */
  27813. releaseInternalTexture(): void;
  27814. /**
  27815. * Get the polynomial representation of the texture data.
  27816. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27817. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27818. */
  27819. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27820. /** @hidden */
  27821. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27822. /** @hidden */
  27823. readonly _lodTextureMid: Nullable<BaseTexture>;
  27824. /** @hidden */
  27825. readonly _lodTextureLow: Nullable<BaseTexture>;
  27826. /**
  27827. * Dispose the texture and release its associated resources.
  27828. */
  27829. dispose(): void;
  27830. /**
  27831. * Serialize the texture into a JSON representation that can be parsed later on.
  27832. * @returns the JSON representation of the texture
  27833. */
  27834. serialize(): any;
  27835. /**
  27836. * Helper function to be called back once a list of texture contains only ready textures.
  27837. * @param textures Define the list of textures to wait for
  27838. * @param callback Define the callback triggered once the entire list will be ready
  27839. */
  27840. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27841. }
  27842. }
  27843. declare module BABYLON {
  27844. /**
  27845. * Class used to store data associated with WebGL texture data for the engine
  27846. * This class should not be used directly
  27847. */
  27848. export class InternalTexture {
  27849. /** @hidden */
  27850. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27851. /**
  27852. * The source of the texture data is unknown
  27853. */
  27854. static DATASOURCE_UNKNOWN: number;
  27855. /**
  27856. * Texture data comes from an URL
  27857. */
  27858. static DATASOURCE_URL: number;
  27859. /**
  27860. * Texture data is only used for temporary storage
  27861. */
  27862. static DATASOURCE_TEMP: number;
  27863. /**
  27864. * Texture data comes from raw data (ArrayBuffer)
  27865. */
  27866. static DATASOURCE_RAW: number;
  27867. /**
  27868. * Texture content is dynamic (video or dynamic texture)
  27869. */
  27870. static DATASOURCE_DYNAMIC: number;
  27871. /**
  27872. * Texture content is generated by rendering to it
  27873. */
  27874. static DATASOURCE_RENDERTARGET: number;
  27875. /**
  27876. * Texture content is part of a multi render target process
  27877. */
  27878. static DATASOURCE_MULTIRENDERTARGET: number;
  27879. /**
  27880. * Texture data comes from a cube data file
  27881. */
  27882. static DATASOURCE_CUBE: number;
  27883. /**
  27884. * Texture data comes from a raw cube data
  27885. */
  27886. static DATASOURCE_CUBERAW: number;
  27887. /**
  27888. * Texture data come from a prefiltered cube data file
  27889. */
  27890. static DATASOURCE_CUBEPREFILTERED: number;
  27891. /**
  27892. * Texture content is raw 3D data
  27893. */
  27894. static DATASOURCE_RAW3D: number;
  27895. /**
  27896. * Texture content is a depth texture
  27897. */
  27898. static DATASOURCE_DEPTHTEXTURE: number;
  27899. /**
  27900. * Texture data comes from a raw cube data encoded with RGBD
  27901. */
  27902. static DATASOURCE_CUBERAW_RGBD: number;
  27903. /**
  27904. * Defines if the texture is ready
  27905. */
  27906. isReady: boolean;
  27907. /**
  27908. * Defines if the texture is a cube texture
  27909. */
  27910. isCube: boolean;
  27911. /**
  27912. * Defines if the texture contains 3D data
  27913. */
  27914. is3D: boolean;
  27915. /**
  27916. * Defines if the texture contains multiview data
  27917. */
  27918. isMultiview: boolean;
  27919. /**
  27920. * Gets the URL used to load this texture
  27921. */
  27922. url: string;
  27923. /**
  27924. * Gets the sampling mode of the texture
  27925. */
  27926. samplingMode: number;
  27927. /**
  27928. * Gets a boolean indicating if the texture needs mipmaps generation
  27929. */
  27930. generateMipMaps: boolean;
  27931. /**
  27932. * Gets the number of samples used by the texture (WebGL2+ only)
  27933. */
  27934. samples: number;
  27935. /**
  27936. * Gets the type of the texture (int, float...)
  27937. */
  27938. type: number;
  27939. /**
  27940. * Gets the format of the texture (RGB, RGBA...)
  27941. */
  27942. format: number;
  27943. /**
  27944. * Observable called when the texture is loaded
  27945. */
  27946. onLoadedObservable: Observable<InternalTexture>;
  27947. /**
  27948. * Gets the width of the texture
  27949. */
  27950. width: number;
  27951. /**
  27952. * Gets the height of the texture
  27953. */
  27954. height: number;
  27955. /**
  27956. * Gets the depth of the texture
  27957. */
  27958. depth: number;
  27959. /**
  27960. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27961. */
  27962. baseWidth: number;
  27963. /**
  27964. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27965. */
  27966. baseHeight: number;
  27967. /**
  27968. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27969. */
  27970. baseDepth: number;
  27971. /**
  27972. * Gets a boolean indicating if the texture is inverted on Y axis
  27973. */
  27974. invertY: boolean;
  27975. /** @hidden */
  27976. _invertVScale: boolean;
  27977. /** @hidden */
  27978. _associatedChannel: number;
  27979. /** @hidden */
  27980. _dataSource: number;
  27981. /** @hidden */
  27982. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27983. /** @hidden */
  27984. _bufferView: Nullable<ArrayBufferView>;
  27985. /** @hidden */
  27986. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27987. /** @hidden */
  27988. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27989. /** @hidden */
  27990. _size: number;
  27991. /** @hidden */
  27992. _extension: string;
  27993. /** @hidden */
  27994. _files: Nullable<string[]>;
  27995. /** @hidden */
  27996. _workingCanvas: Nullable<HTMLCanvasElement>;
  27997. /** @hidden */
  27998. _workingContext: Nullable<CanvasRenderingContext2D>;
  27999. /** @hidden */
  28000. _framebuffer: Nullable<WebGLFramebuffer>;
  28001. /** @hidden */
  28002. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28003. /** @hidden */
  28004. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28005. /** @hidden */
  28006. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28007. /** @hidden */
  28008. _attachments: Nullable<number[]>;
  28009. /** @hidden */
  28010. _cachedCoordinatesMode: Nullable<number>;
  28011. /** @hidden */
  28012. _cachedWrapU: Nullable<number>;
  28013. /** @hidden */
  28014. _cachedWrapV: Nullable<number>;
  28015. /** @hidden */
  28016. _cachedWrapR: Nullable<number>;
  28017. /** @hidden */
  28018. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28019. /** @hidden */
  28020. _isDisabled: boolean;
  28021. /** @hidden */
  28022. _compression: Nullable<string>;
  28023. /** @hidden */
  28024. _generateStencilBuffer: boolean;
  28025. /** @hidden */
  28026. _generateDepthBuffer: boolean;
  28027. /** @hidden */
  28028. _comparisonFunction: number;
  28029. /** @hidden */
  28030. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28031. /** @hidden */
  28032. _lodGenerationScale: number;
  28033. /** @hidden */
  28034. _lodGenerationOffset: number;
  28035. /** @hidden */
  28036. _colorTextureArray: Nullable<WebGLTexture>;
  28037. /** @hidden */
  28038. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28039. /** @hidden */
  28040. _lodTextureHigh: Nullable<BaseTexture>;
  28041. /** @hidden */
  28042. _lodTextureMid: Nullable<BaseTexture>;
  28043. /** @hidden */
  28044. _lodTextureLow: Nullable<BaseTexture>;
  28045. /** @hidden */
  28046. _isRGBD: boolean;
  28047. /** @hidden */
  28048. _linearSpecularLOD: boolean;
  28049. /** @hidden */
  28050. _irradianceTexture: Nullable<BaseTexture>;
  28051. /** @hidden */
  28052. _webGLTexture: Nullable<WebGLTexture>;
  28053. /** @hidden */
  28054. _references: number;
  28055. private _engine;
  28056. /**
  28057. * Gets the Engine the texture belongs to.
  28058. * @returns The babylon engine
  28059. */
  28060. getEngine(): Engine;
  28061. /**
  28062. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28063. */
  28064. readonly dataSource: number;
  28065. /**
  28066. * Creates a new InternalTexture
  28067. * @param engine defines the engine to use
  28068. * @param dataSource defines the type of data that will be used
  28069. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28070. */
  28071. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28072. /**
  28073. * Increments the number of references (ie. the number of Texture that point to it)
  28074. */
  28075. incrementReferences(): void;
  28076. /**
  28077. * Change the size of the texture (not the size of the content)
  28078. * @param width defines the new width
  28079. * @param height defines the new height
  28080. * @param depth defines the new depth (1 by default)
  28081. */
  28082. updateSize(width: int, height: int, depth?: int): void;
  28083. /** @hidden */
  28084. _rebuild(): void;
  28085. /** @hidden */
  28086. _swapAndDie(target: InternalTexture): void;
  28087. /**
  28088. * Dispose the current allocated resources
  28089. */
  28090. dispose(): void;
  28091. }
  28092. }
  28093. declare module BABYLON {
  28094. /**
  28095. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28096. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28097. */
  28098. export class EffectFallbacks {
  28099. private _defines;
  28100. private _currentRank;
  28101. private _maxRank;
  28102. private _mesh;
  28103. /**
  28104. * Removes the fallback from the bound mesh.
  28105. */
  28106. unBindMesh(): void;
  28107. /**
  28108. * Adds a fallback on the specified property.
  28109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28110. * @param define The name of the define in the shader
  28111. */
  28112. addFallback(rank: number, define: string): void;
  28113. /**
  28114. * Sets the mesh to use CPU skinning when needing to fallback.
  28115. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28116. * @param mesh The mesh to use the fallbacks.
  28117. */
  28118. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28119. /**
  28120. * Checks to see if more fallbacks are still availible.
  28121. */
  28122. readonly isMoreFallbacks: boolean;
  28123. /**
  28124. * Removes the defines that should be removed when falling back.
  28125. * @param currentDefines defines the current define statements for the shader.
  28126. * @param effect defines the current effect we try to compile
  28127. * @returns The resulting defines with defines of the current rank removed.
  28128. */
  28129. reduce(currentDefines: string, effect: Effect): string;
  28130. }
  28131. /**
  28132. * Options to be used when creating an effect.
  28133. */
  28134. export class EffectCreationOptions {
  28135. /**
  28136. * Atrributes that will be used in the shader.
  28137. */
  28138. attributes: string[];
  28139. /**
  28140. * Uniform varible names that will be set in the shader.
  28141. */
  28142. uniformsNames: string[];
  28143. /**
  28144. * Uniform buffer varible names that will be set in the shader.
  28145. */
  28146. uniformBuffersNames: string[];
  28147. /**
  28148. * Sampler texture variable names that will be set in the shader.
  28149. */
  28150. samplers: string[];
  28151. /**
  28152. * Define statements that will be set in the shader.
  28153. */
  28154. defines: any;
  28155. /**
  28156. * Possible fallbacks for this effect to improve performance when needed.
  28157. */
  28158. fallbacks: Nullable<EffectFallbacks>;
  28159. /**
  28160. * Callback that will be called when the shader is compiled.
  28161. */
  28162. onCompiled: Nullable<(effect: Effect) => void>;
  28163. /**
  28164. * Callback that will be called if an error occurs during shader compilation.
  28165. */
  28166. onError: Nullable<(effect: Effect, errors: string) => void>;
  28167. /**
  28168. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28169. */
  28170. indexParameters: any;
  28171. /**
  28172. * Max number of lights that can be used in the shader.
  28173. */
  28174. maxSimultaneousLights: number;
  28175. /**
  28176. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28177. */
  28178. transformFeedbackVaryings: Nullable<string[]>;
  28179. }
  28180. /**
  28181. * Effect containing vertex and fragment shader that can be executed on an object.
  28182. */
  28183. export class Effect implements IDisposable {
  28184. /**
  28185. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28186. */
  28187. static ShadersRepository: string;
  28188. /**
  28189. * Name of the effect.
  28190. */
  28191. name: any;
  28192. /**
  28193. * String container all the define statements that should be set on the shader.
  28194. */
  28195. defines: string;
  28196. /**
  28197. * Callback that will be called when the shader is compiled.
  28198. */
  28199. onCompiled: Nullable<(effect: Effect) => void>;
  28200. /**
  28201. * Callback that will be called if an error occurs during shader compilation.
  28202. */
  28203. onError: Nullable<(effect: Effect, errors: string) => void>;
  28204. /**
  28205. * Callback that will be called when effect is bound.
  28206. */
  28207. onBind: Nullable<(effect: Effect) => void>;
  28208. /**
  28209. * Unique ID of the effect.
  28210. */
  28211. uniqueId: number;
  28212. /**
  28213. * Observable that will be called when the shader is compiled.
  28214. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28215. */
  28216. onCompileObservable: Observable<Effect>;
  28217. /**
  28218. * Observable that will be called if an error occurs during shader compilation.
  28219. */
  28220. onErrorObservable: Observable<Effect>;
  28221. /** @hidden */
  28222. _onBindObservable: Nullable<Observable<Effect>>;
  28223. /**
  28224. * Observable that will be called when effect is bound.
  28225. */
  28226. readonly onBindObservable: Observable<Effect>;
  28227. /** @hidden */
  28228. _bonesComputationForcedToCPU: boolean;
  28229. private static _uniqueIdSeed;
  28230. private _engine;
  28231. private _uniformBuffersNames;
  28232. private _uniformsNames;
  28233. private _samplerList;
  28234. private _samplers;
  28235. private _isReady;
  28236. private _compilationError;
  28237. private _attributesNames;
  28238. private _attributes;
  28239. private _uniforms;
  28240. /**
  28241. * Key for the effect.
  28242. * @hidden
  28243. */
  28244. _key: string;
  28245. private _indexParameters;
  28246. private _fallbacks;
  28247. private _vertexSourceCode;
  28248. private _fragmentSourceCode;
  28249. private _vertexSourceCodeOverride;
  28250. private _fragmentSourceCodeOverride;
  28251. private _transformFeedbackVaryings;
  28252. /**
  28253. * Compiled shader to webGL program.
  28254. * @hidden
  28255. */
  28256. _pipelineContext: Nullable<IPipelineContext>;
  28257. private _valueCache;
  28258. private static _baseCache;
  28259. /**
  28260. * Instantiates an effect.
  28261. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28262. * @param baseName Name of the effect.
  28263. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28264. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28265. * @param samplers List of sampler variables that will be passed to the shader.
  28266. * @param engine Engine to be used to render the effect
  28267. * @param defines Define statements to be added to the shader.
  28268. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28269. * @param onCompiled Callback that will be called when the shader is compiled.
  28270. * @param onError Callback that will be called if an error occurs during shader compilation.
  28271. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28272. */
  28273. 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);
  28274. private _useFinalCode;
  28275. /**
  28276. * Unique key for this effect
  28277. */
  28278. readonly key: string;
  28279. /**
  28280. * If the effect has been compiled and prepared.
  28281. * @returns if the effect is compiled and prepared.
  28282. */
  28283. isReady(): boolean;
  28284. /**
  28285. * The engine the effect was initialized with.
  28286. * @returns the engine.
  28287. */
  28288. getEngine(): Engine;
  28289. /**
  28290. * The pipeline context for this effect
  28291. * @returns the associated pipeline context
  28292. */
  28293. getPipelineContext(): Nullable<IPipelineContext>;
  28294. /**
  28295. * The set of names of attribute variables for the shader.
  28296. * @returns An array of attribute names.
  28297. */
  28298. getAttributesNames(): string[];
  28299. /**
  28300. * Returns the attribute at the given index.
  28301. * @param index The index of the attribute.
  28302. * @returns The location of the attribute.
  28303. */
  28304. getAttributeLocation(index: number): number;
  28305. /**
  28306. * Returns the attribute based on the name of the variable.
  28307. * @param name of the attribute to look up.
  28308. * @returns the attribute location.
  28309. */
  28310. getAttributeLocationByName(name: string): number;
  28311. /**
  28312. * The number of attributes.
  28313. * @returns the numnber of attributes.
  28314. */
  28315. getAttributesCount(): number;
  28316. /**
  28317. * Gets the index of a uniform variable.
  28318. * @param uniformName of the uniform to look up.
  28319. * @returns the index.
  28320. */
  28321. getUniformIndex(uniformName: string): number;
  28322. /**
  28323. * Returns the attribute based on the name of the variable.
  28324. * @param uniformName of the uniform to look up.
  28325. * @returns the location of the uniform.
  28326. */
  28327. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28328. /**
  28329. * Returns an array of sampler variable names
  28330. * @returns The array of sampler variable neames.
  28331. */
  28332. getSamplers(): string[];
  28333. /**
  28334. * The error from the last compilation.
  28335. * @returns the error string.
  28336. */
  28337. getCompilationError(): string;
  28338. /**
  28339. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28340. * @param func The callback to be used.
  28341. */
  28342. executeWhenCompiled(func: (effect: Effect) => void): void;
  28343. private _checkIsReady;
  28344. /** @hidden */
  28345. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28346. /** @hidden */
  28347. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28348. /** @hidden */
  28349. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28350. /**
  28351. * Recompiles the webGL program
  28352. * @param vertexSourceCode The source code for the vertex shader.
  28353. * @param fragmentSourceCode The source code for the fragment shader.
  28354. * @param onCompiled Callback called when completed.
  28355. * @param onError Callback called on error.
  28356. * @hidden
  28357. */
  28358. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28359. /**
  28360. * Prepares the effect
  28361. * @hidden
  28362. */
  28363. _prepareEffect(): void;
  28364. /**
  28365. * Checks if the effect is supported. (Must be called after compilation)
  28366. */
  28367. readonly isSupported: boolean;
  28368. /**
  28369. * Binds a texture to the engine to be used as output of the shader.
  28370. * @param channel Name of the output variable.
  28371. * @param texture Texture to bind.
  28372. * @hidden
  28373. */
  28374. _bindTexture(channel: string, texture: InternalTexture): void;
  28375. /**
  28376. * Sets a texture on the engine to be used in the shader.
  28377. * @param channel Name of the sampler variable.
  28378. * @param texture Texture to set.
  28379. */
  28380. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28381. /**
  28382. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28383. * @param channel Name of the sampler variable.
  28384. * @param texture Texture to set.
  28385. */
  28386. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28387. /**
  28388. * Sets an array of textures on the engine to be used in the shader.
  28389. * @param channel Name of the variable.
  28390. * @param textures Textures to set.
  28391. */
  28392. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28393. /**
  28394. * 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)
  28395. * @param channel Name of the sampler variable.
  28396. * @param postProcess Post process to get the input texture from.
  28397. */
  28398. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28399. /**
  28400. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28401. * 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)
  28402. * @param channel Name of the sampler variable.
  28403. * @param postProcess Post process to get the output texture from.
  28404. */
  28405. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28406. /** @hidden */
  28407. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28408. /** @hidden */
  28409. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28410. /** @hidden */
  28411. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28412. /** @hidden */
  28413. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28414. /**
  28415. * Binds a buffer to a uniform.
  28416. * @param buffer Buffer to bind.
  28417. * @param name Name of the uniform variable to bind to.
  28418. */
  28419. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28420. /**
  28421. * Binds block to a uniform.
  28422. * @param blockName Name of the block to bind.
  28423. * @param index Index to bind.
  28424. */
  28425. bindUniformBlock(blockName: string, index: number): void;
  28426. /**
  28427. * Sets an interger value on a uniform variable.
  28428. * @param uniformName Name of the variable.
  28429. * @param value Value to be set.
  28430. * @returns this effect.
  28431. */
  28432. setInt(uniformName: string, value: number): Effect;
  28433. /**
  28434. * Sets an int array on a uniform variable.
  28435. * @param uniformName Name of the variable.
  28436. * @param array array to be set.
  28437. * @returns this effect.
  28438. */
  28439. setIntArray(uniformName: string, array: Int32Array): Effect;
  28440. /**
  28441. * 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)
  28442. * @param uniformName Name of the variable.
  28443. * @param array array to be set.
  28444. * @returns this effect.
  28445. */
  28446. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28447. /**
  28448. * 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)
  28449. * @param uniformName Name of the variable.
  28450. * @param array array to be set.
  28451. * @returns this effect.
  28452. */
  28453. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28454. /**
  28455. * 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)
  28456. * @param uniformName Name of the variable.
  28457. * @param array array to be set.
  28458. * @returns this effect.
  28459. */
  28460. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28461. /**
  28462. * Sets an float array on a uniform variable.
  28463. * @param uniformName Name of the variable.
  28464. * @param array array to be set.
  28465. * @returns this effect.
  28466. */
  28467. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28468. /**
  28469. * 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)
  28470. * @param uniformName Name of the variable.
  28471. * @param array array to be set.
  28472. * @returns this effect.
  28473. */
  28474. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28475. /**
  28476. * 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)
  28477. * @param uniformName Name of the variable.
  28478. * @param array array to be set.
  28479. * @returns this effect.
  28480. */
  28481. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28482. /**
  28483. * 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)
  28484. * @param uniformName Name of the variable.
  28485. * @param array array to be set.
  28486. * @returns this effect.
  28487. */
  28488. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28489. /**
  28490. * Sets an array on a uniform variable.
  28491. * @param uniformName Name of the variable.
  28492. * @param array array to be set.
  28493. * @returns this effect.
  28494. */
  28495. setArray(uniformName: string, array: number[]): Effect;
  28496. /**
  28497. * 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)
  28498. * @param uniformName Name of the variable.
  28499. * @param array array to be set.
  28500. * @returns this effect.
  28501. */
  28502. setArray2(uniformName: string, array: number[]): Effect;
  28503. /**
  28504. * 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)
  28505. * @param uniformName Name of the variable.
  28506. * @param array array to be set.
  28507. * @returns this effect.
  28508. */
  28509. setArray3(uniformName: string, array: number[]): Effect;
  28510. /**
  28511. * 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)
  28512. * @param uniformName Name of the variable.
  28513. * @param array array to be set.
  28514. * @returns this effect.
  28515. */
  28516. setArray4(uniformName: string, array: number[]): Effect;
  28517. /**
  28518. * Sets matrices on a uniform variable.
  28519. * @param uniformName Name of the variable.
  28520. * @param matrices matrices to be set.
  28521. * @returns this effect.
  28522. */
  28523. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28524. /**
  28525. * Sets matrix on a uniform variable.
  28526. * @param uniformName Name of the variable.
  28527. * @param matrix matrix to be set.
  28528. * @returns this effect.
  28529. */
  28530. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28531. /**
  28532. * 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)
  28533. * @param uniformName Name of the variable.
  28534. * @param matrix matrix to be set.
  28535. * @returns this effect.
  28536. */
  28537. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28538. /**
  28539. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28540. * @param uniformName Name of the variable.
  28541. * @param matrix matrix to be set.
  28542. * @returns this effect.
  28543. */
  28544. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28545. /**
  28546. * Sets a float on a uniform variable.
  28547. * @param uniformName Name of the variable.
  28548. * @param value value to be set.
  28549. * @returns this effect.
  28550. */
  28551. setFloat(uniformName: string, value: number): Effect;
  28552. /**
  28553. * Sets a boolean on a uniform variable.
  28554. * @param uniformName Name of the variable.
  28555. * @param bool value to be set.
  28556. * @returns this effect.
  28557. */
  28558. setBool(uniformName: string, bool: boolean): Effect;
  28559. /**
  28560. * Sets a Vector2 on a uniform variable.
  28561. * @param uniformName Name of the variable.
  28562. * @param vector2 vector2 to be set.
  28563. * @returns this effect.
  28564. */
  28565. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28566. /**
  28567. * Sets a float2 on a uniform variable.
  28568. * @param uniformName Name of the variable.
  28569. * @param x First float in float2.
  28570. * @param y Second float in float2.
  28571. * @returns this effect.
  28572. */
  28573. setFloat2(uniformName: string, x: number, y: number): Effect;
  28574. /**
  28575. * Sets a Vector3 on a uniform variable.
  28576. * @param uniformName Name of the variable.
  28577. * @param vector3 Value to be set.
  28578. * @returns this effect.
  28579. */
  28580. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28581. /**
  28582. * Sets a float3 on a uniform variable.
  28583. * @param uniformName Name of the variable.
  28584. * @param x First float in float3.
  28585. * @param y Second float in float3.
  28586. * @param z Third float in float3.
  28587. * @returns this effect.
  28588. */
  28589. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28590. /**
  28591. * Sets a Vector4 on a uniform variable.
  28592. * @param uniformName Name of the variable.
  28593. * @param vector4 Value to be set.
  28594. * @returns this effect.
  28595. */
  28596. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28597. /**
  28598. * Sets a float4 on a uniform variable.
  28599. * @param uniformName Name of the variable.
  28600. * @param x First float in float4.
  28601. * @param y Second float in float4.
  28602. * @param z Third float in float4.
  28603. * @param w Fourth float in float4.
  28604. * @returns this effect.
  28605. */
  28606. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28607. /**
  28608. * Sets a Color3 on a uniform variable.
  28609. * @param uniformName Name of the variable.
  28610. * @param color3 Value to be set.
  28611. * @returns this effect.
  28612. */
  28613. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28614. /**
  28615. * Sets a Color4 on a uniform variable.
  28616. * @param uniformName Name of the variable.
  28617. * @param color3 Value to be set.
  28618. * @param alpha Alpha value to be set.
  28619. * @returns this effect.
  28620. */
  28621. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28622. /**
  28623. * Sets a Color4 on a uniform variable
  28624. * @param uniformName defines the name of the variable
  28625. * @param color4 defines the value to be set
  28626. * @returns this effect.
  28627. */
  28628. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28629. /** Release all associated resources */
  28630. dispose(): void;
  28631. /**
  28632. * This function will add a new shader to the shader store
  28633. * @param name the name of the shader
  28634. * @param pixelShader optional pixel shader content
  28635. * @param vertexShader optional vertex shader content
  28636. */
  28637. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28638. /**
  28639. * Store of each shader (The can be looked up using effect.key)
  28640. */
  28641. static ShadersStore: {
  28642. [key: string]: string;
  28643. };
  28644. /**
  28645. * Store of each included file for a shader (The can be looked up using effect.key)
  28646. */
  28647. static IncludesShadersStore: {
  28648. [key: string]: string;
  28649. };
  28650. /**
  28651. * Resets the cache of effects.
  28652. */
  28653. static ResetCache(): void;
  28654. }
  28655. }
  28656. declare module BABYLON {
  28657. /**
  28658. * Uniform buffer objects.
  28659. *
  28660. * Handles blocks of uniform on the GPU.
  28661. *
  28662. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28663. *
  28664. * For more information, please refer to :
  28665. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28666. */
  28667. export class UniformBuffer {
  28668. private _engine;
  28669. private _buffer;
  28670. private _data;
  28671. private _bufferData;
  28672. private _dynamic?;
  28673. private _uniformLocations;
  28674. private _uniformSizes;
  28675. private _uniformLocationPointer;
  28676. private _needSync;
  28677. private _noUBO;
  28678. private _currentEffect;
  28679. private static _MAX_UNIFORM_SIZE;
  28680. private static _tempBuffer;
  28681. /**
  28682. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28683. * This is dynamic to allow compat with webgl 1 and 2.
  28684. * You will need to pass the name of the uniform as well as the value.
  28685. */
  28686. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28687. /**
  28688. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28689. * This is dynamic to allow compat with webgl 1 and 2.
  28690. * You will need to pass the name of the uniform as well as the value.
  28691. */
  28692. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28693. /**
  28694. * Lambda to Update a single float in a uniform buffer.
  28695. * This is dynamic to allow compat with webgl 1 and 2.
  28696. * You will need to pass the name of the uniform as well as the value.
  28697. */
  28698. updateFloat: (name: string, x: number) => void;
  28699. /**
  28700. * Lambda to Update a vec2 of float in a uniform buffer.
  28701. * This is dynamic to allow compat with webgl 1 and 2.
  28702. * You will need to pass the name of the uniform as well as the value.
  28703. */
  28704. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28705. /**
  28706. * Lambda to Update a vec3 of float in a uniform buffer.
  28707. * This is dynamic to allow compat with webgl 1 and 2.
  28708. * You will need to pass the name of the uniform as well as the value.
  28709. */
  28710. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28711. /**
  28712. * Lambda to Update a vec4 of float in a uniform buffer.
  28713. * This is dynamic to allow compat with webgl 1 and 2.
  28714. * You will need to pass the name of the uniform as well as the value.
  28715. */
  28716. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28717. /**
  28718. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28719. * This is dynamic to allow compat with webgl 1 and 2.
  28720. * You will need to pass the name of the uniform as well as the value.
  28721. */
  28722. updateMatrix: (name: string, mat: Matrix) => void;
  28723. /**
  28724. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28725. * This is dynamic to allow compat with webgl 1 and 2.
  28726. * You will need to pass the name of the uniform as well as the value.
  28727. */
  28728. updateVector3: (name: string, vector: Vector3) => void;
  28729. /**
  28730. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28731. * This is dynamic to allow compat with webgl 1 and 2.
  28732. * You will need to pass the name of the uniform as well as the value.
  28733. */
  28734. updateVector4: (name: string, vector: Vector4) => void;
  28735. /**
  28736. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28737. * This is dynamic to allow compat with webgl 1 and 2.
  28738. * You will need to pass the name of the uniform as well as the value.
  28739. */
  28740. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28741. /**
  28742. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28743. * This is dynamic to allow compat with webgl 1 and 2.
  28744. * You will need to pass the name of the uniform as well as the value.
  28745. */
  28746. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28747. /**
  28748. * Instantiates a new Uniform buffer objects.
  28749. *
  28750. * Handles blocks of uniform on the GPU.
  28751. *
  28752. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28753. *
  28754. * For more information, please refer to :
  28755. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28756. * @param engine Define the engine the buffer is associated with
  28757. * @param data Define the data contained in the buffer
  28758. * @param dynamic Define if the buffer is updatable
  28759. */
  28760. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28761. /**
  28762. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28763. * or just falling back on setUniformXXX calls.
  28764. */
  28765. readonly useUbo: boolean;
  28766. /**
  28767. * Indicates if the WebGL underlying uniform buffer is in sync
  28768. * with the javascript cache data.
  28769. */
  28770. readonly isSync: boolean;
  28771. /**
  28772. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28773. * Also, a dynamic UniformBuffer will disable cache verification and always
  28774. * update the underlying WebGL uniform buffer to the GPU.
  28775. * @returns if Dynamic, otherwise false
  28776. */
  28777. isDynamic(): boolean;
  28778. /**
  28779. * The data cache on JS side.
  28780. * @returns the underlying data as a float array
  28781. */
  28782. getData(): Float32Array;
  28783. /**
  28784. * The underlying WebGL Uniform buffer.
  28785. * @returns the webgl buffer
  28786. */
  28787. getBuffer(): Nullable<DataBuffer>;
  28788. /**
  28789. * std140 layout specifies how to align data within an UBO structure.
  28790. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28791. * for specs.
  28792. */
  28793. private _fillAlignment;
  28794. /**
  28795. * Adds an uniform in the buffer.
  28796. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28797. * for the layout to be correct !
  28798. * @param name Name of the uniform, as used in the uniform block in the shader.
  28799. * @param size Data size, or data directly.
  28800. */
  28801. addUniform(name: string, size: number | number[]): void;
  28802. /**
  28803. * Adds a Matrix 4x4 to the uniform buffer.
  28804. * @param name Name of the uniform, as used in the uniform block in the shader.
  28805. * @param mat A 4x4 matrix.
  28806. */
  28807. addMatrix(name: string, mat: Matrix): void;
  28808. /**
  28809. * Adds a vec2 to the uniform buffer.
  28810. * @param name Name of the uniform, as used in the uniform block in the shader.
  28811. * @param x Define the x component value of the vec2
  28812. * @param y Define the y component value of the vec2
  28813. */
  28814. addFloat2(name: string, x: number, y: number): void;
  28815. /**
  28816. * Adds a vec3 to the uniform buffer.
  28817. * @param name Name of the uniform, as used in the uniform block in the shader.
  28818. * @param x Define the x component value of the vec3
  28819. * @param y Define the y component value of the vec3
  28820. * @param z Define the z component value of the vec3
  28821. */
  28822. addFloat3(name: string, x: number, y: number, z: number): void;
  28823. /**
  28824. * Adds a vec3 to the uniform buffer.
  28825. * @param name Name of the uniform, as used in the uniform block in the shader.
  28826. * @param color Define the vec3 from a Color
  28827. */
  28828. addColor3(name: string, color: Color3): void;
  28829. /**
  28830. * Adds a vec4 to the uniform buffer.
  28831. * @param name Name of the uniform, as used in the uniform block in the shader.
  28832. * @param color Define the rgb components from a Color
  28833. * @param alpha Define the a component of the vec4
  28834. */
  28835. addColor4(name: string, color: Color3, alpha: number): void;
  28836. /**
  28837. * Adds a vec3 to the uniform buffer.
  28838. * @param name Name of the uniform, as used in the uniform block in the shader.
  28839. * @param vector Define the vec3 components from a Vector
  28840. */
  28841. addVector3(name: string, vector: Vector3): void;
  28842. /**
  28843. * Adds a Matrix 3x3 to the uniform buffer.
  28844. * @param name Name of the uniform, as used in the uniform block in the shader.
  28845. */
  28846. addMatrix3x3(name: string): void;
  28847. /**
  28848. * Adds a Matrix 2x2 to the uniform buffer.
  28849. * @param name Name of the uniform, as used in the uniform block in the shader.
  28850. */
  28851. addMatrix2x2(name: string): void;
  28852. /**
  28853. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28854. */
  28855. create(): void;
  28856. /** @hidden */
  28857. _rebuild(): void;
  28858. /**
  28859. * Updates the WebGL Uniform Buffer on the GPU.
  28860. * If the `dynamic` flag is set to true, no cache comparison is done.
  28861. * Otherwise, the buffer will be updated only if the cache differs.
  28862. */
  28863. update(): void;
  28864. /**
  28865. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28866. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28867. * @param data Define the flattened data
  28868. * @param size Define the size of the data.
  28869. */
  28870. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28871. private _updateMatrix3x3ForUniform;
  28872. private _updateMatrix3x3ForEffect;
  28873. private _updateMatrix2x2ForEffect;
  28874. private _updateMatrix2x2ForUniform;
  28875. private _updateFloatForEffect;
  28876. private _updateFloatForUniform;
  28877. private _updateFloat2ForEffect;
  28878. private _updateFloat2ForUniform;
  28879. private _updateFloat3ForEffect;
  28880. private _updateFloat3ForUniform;
  28881. private _updateFloat4ForEffect;
  28882. private _updateFloat4ForUniform;
  28883. private _updateMatrixForEffect;
  28884. private _updateMatrixForUniform;
  28885. private _updateVector3ForEffect;
  28886. private _updateVector3ForUniform;
  28887. private _updateVector4ForEffect;
  28888. private _updateVector4ForUniform;
  28889. private _updateColor3ForEffect;
  28890. private _updateColor3ForUniform;
  28891. private _updateColor4ForEffect;
  28892. private _updateColor4ForUniform;
  28893. /**
  28894. * Sets a sampler uniform on the effect.
  28895. * @param name Define the name of the sampler.
  28896. * @param texture Define the texture to set in the sampler
  28897. */
  28898. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28899. /**
  28900. * Directly updates the value of the uniform in the cache AND on the GPU.
  28901. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28902. * @param data Define the flattened data
  28903. */
  28904. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28905. /**
  28906. * Binds this uniform buffer to an effect.
  28907. * @param effect Define the effect to bind the buffer to
  28908. * @param name Name of the uniform block in the shader.
  28909. */
  28910. bindToEffect(effect: Effect, name: string): void;
  28911. /**
  28912. * Disposes the uniform buffer.
  28913. */
  28914. dispose(): void;
  28915. }
  28916. }
  28917. declare module BABYLON {
  28918. /**
  28919. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28921. */
  28922. export class Analyser {
  28923. /**
  28924. * Gets or sets the smoothing
  28925. * @ignorenaming
  28926. */
  28927. SMOOTHING: number;
  28928. /**
  28929. * Gets or sets the FFT table size
  28930. * @ignorenaming
  28931. */
  28932. FFT_SIZE: number;
  28933. /**
  28934. * Gets or sets the bar graph amplitude
  28935. * @ignorenaming
  28936. */
  28937. BARGRAPHAMPLITUDE: number;
  28938. /**
  28939. * Gets or sets the position of the debug canvas
  28940. * @ignorenaming
  28941. */
  28942. DEBUGCANVASPOS: {
  28943. x: number;
  28944. y: number;
  28945. };
  28946. /**
  28947. * Gets or sets the debug canvas size
  28948. * @ignorenaming
  28949. */
  28950. DEBUGCANVASSIZE: {
  28951. width: number;
  28952. height: number;
  28953. };
  28954. private _byteFreqs;
  28955. private _byteTime;
  28956. private _floatFreqs;
  28957. private _webAudioAnalyser;
  28958. private _debugCanvas;
  28959. private _debugCanvasContext;
  28960. private _scene;
  28961. private _registerFunc;
  28962. private _audioEngine;
  28963. /**
  28964. * Creates a new analyser
  28965. * @param scene defines hosting scene
  28966. */
  28967. constructor(scene: Scene);
  28968. /**
  28969. * Get the number of data values you will have to play with for the visualization
  28970. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28971. * @returns a number
  28972. */
  28973. getFrequencyBinCount(): number;
  28974. /**
  28975. * Gets the current frequency data as a byte array
  28976. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28977. * @returns a Uint8Array
  28978. */
  28979. getByteFrequencyData(): Uint8Array;
  28980. /**
  28981. * Gets the current waveform as a byte array
  28982. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28983. * @returns a Uint8Array
  28984. */
  28985. getByteTimeDomainData(): Uint8Array;
  28986. /**
  28987. * Gets the current frequency data as a float array
  28988. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28989. * @returns a Float32Array
  28990. */
  28991. getFloatFrequencyData(): Float32Array;
  28992. /**
  28993. * Renders the debug canvas
  28994. */
  28995. drawDebugCanvas(): void;
  28996. /**
  28997. * Stops rendering the debug canvas and removes it
  28998. */
  28999. stopDebugCanvas(): void;
  29000. /**
  29001. * Connects two audio nodes
  29002. * @param inputAudioNode defines first node to connect
  29003. * @param outputAudioNode defines second node to connect
  29004. */
  29005. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29006. /**
  29007. * Releases all associated resources
  29008. */
  29009. dispose(): void;
  29010. }
  29011. }
  29012. declare module BABYLON {
  29013. /**
  29014. * This represents an audio engine and it is responsible
  29015. * to play, synchronize and analyse sounds throughout the application.
  29016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29017. */
  29018. export interface IAudioEngine extends IDisposable {
  29019. /**
  29020. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29021. */
  29022. readonly canUseWebAudio: boolean;
  29023. /**
  29024. * Gets the current AudioContext if available.
  29025. */
  29026. readonly audioContext: Nullable<AudioContext>;
  29027. /**
  29028. * The master gain node defines the global audio volume of your audio engine.
  29029. */
  29030. readonly masterGain: GainNode;
  29031. /**
  29032. * Gets whether or not mp3 are supported by your browser.
  29033. */
  29034. readonly isMP3supported: boolean;
  29035. /**
  29036. * Gets whether or not ogg are supported by your browser.
  29037. */
  29038. readonly isOGGsupported: boolean;
  29039. /**
  29040. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29041. * @ignoreNaming
  29042. */
  29043. WarnedWebAudioUnsupported: boolean;
  29044. /**
  29045. * Defines if the audio engine relies on a custom unlocked button.
  29046. * In this case, the embedded button will not be displayed.
  29047. */
  29048. useCustomUnlockedButton: boolean;
  29049. /**
  29050. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29051. */
  29052. readonly unlocked: boolean;
  29053. /**
  29054. * Event raised when audio has been unlocked on the browser.
  29055. */
  29056. onAudioUnlockedObservable: Observable<AudioEngine>;
  29057. /**
  29058. * Event raised when audio has been locked on the browser.
  29059. */
  29060. onAudioLockedObservable: Observable<AudioEngine>;
  29061. /**
  29062. * Flags the audio engine in Locked state.
  29063. * This happens due to new browser policies preventing audio to autoplay.
  29064. */
  29065. lock(): void;
  29066. /**
  29067. * Unlocks the audio engine once a user action has been done on the dom.
  29068. * This is helpful to resume play once browser policies have been satisfied.
  29069. */
  29070. unlock(): void;
  29071. }
  29072. /**
  29073. * This represents the default audio engine used in babylon.
  29074. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29076. */
  29077. export class AudioEngine implements IAudioEngine {
  29078. private _audioContext;
  29079. private _audioContextInitialized;
  29080. private _muteButton;
  29081. private _hostElement;
  29082. /**
  29083. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29084. */
  29085. canUseWebAudio: boolean;
  29086. /**
  29087. * The master gain node defines the global audio volume of your audio engine.
  29088. */
  29089. masterGain: GainNode;
  29090. /**
  29091. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29092. * @ignoreNaming
  29093. */
  29094. WarnedWebAudioUnsupported: boolean;
  29095. /**
  29096. * Gets whether or not mp3 are supported by your browser.
  29097. */
  29098. isMP3supported: boolean;
  29099. /**
  29100. * Gets whether or not ogg are supported by your browser.
  29101. */
  29102. isOGGsupported: boolean;
  29103. /**
  29104. * Gets whether audio has been unlocked on the device.
  29105. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29106. * a user interaction has happened.
  29107. */
  29108. unlocked: boolean;
  29109. /**
  29110. * Defines if the audio engine relies on a custom unlocked button.
  29111. * In this case, the embedded button will not be displayed.
  29112. */
  29113. useCustomUnlockedButton: boolean;
  29114. /**
  29115. * Event raised when audio has been unlocked on the browser.
  29116. */
  29117. onAudioUnlockedObservable: Observable<AudioEngine>;
  29118. /**
  29119. * Event raised when audio has been locked on the browser.
  29120. */
  29121. onAudioLockedObservable: Observable<AudioEngine>;
  29122. /**
  29123. * Gets the current AudioContext if available.
  29124. */
  29125. readonly audioContext: Nullable<AudioContext>;
  29126. private _connectedAnalyser;
  29127. /**
  29128. * Instantiates a new audio engine.
  29129. *
  29130. * There should be only one per page as some browsers restrict the number
  29131. * of audio contexts you can create.
  29132. * @param hostElement defines the host element where to display the mute icon if necessary
  29133. */
  29134. constructor(hostElement?: Nullable<HTMLElement>);
  29135. /**
  29136. * Flags the audio engine in Locked state.
  29137. * This happens due to new browser policies preventing audio to autoplay.
  29138. */
  29139. lock(): void;
  29140. /**
  29141. * Unlocks the audio engine once a user action has been done on the dom.
  29142. * This is helpful to resume play once browser policies have been satisfied.
  29143. */
  29144. unlock(): void;
  29145. private _resumeAudioContext;
  29146. private _initializeAudioContext;
  29147. private _tryToRun;
  29148. private _triggerRunningState;
  29149. private _triggerSuspendedState;
  29150. private _displayMuteButton;
  29151. private _moveButtonToTopLeft;
  29152. private _onResize;
  29153. private _hideMuteButton;
  29154. /**
  29155. * Destroy and release the resources associated with the audio ccontext.
  29156. */
  29157. dispose(): void;
  29158. /**
  29159. * Gets the global volume sets on the master gain.
  29160. * @returns the global volume if set or -1 otherwise
  29161. */
  29162. getGlobalVolume(): number;
  29163. /**
  29164. * Sets the global volume of your experience (sets on the master gain).
  29165. * @param newVolume Defines the new global volume of the application
  29166. */
  29167. setGlobalVolume(newVolume: number): void;
  29168. /**
  29169. * Connect the audio engine to an audio analyser allowing some amazing
  29170. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29172. * @param analyser The analyser to connect to the engine
  29173. */
  29174. connectToAnalyser(analyser: Analyser): void;
  29175. }
  29176. }
  29177. declare module BABYLON {
  29178. /**
  29179. * Interface used to present a loading screen while loading a scene
  29180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29181. */
  29182. export interface ILoadingScreen {
  29183. /**
  29184. * Function called to display the loading screen
  29185. */
  29186. displayLoadingUI: () => void;
  29187. /**
  29188. * Function called to hide the loading screen
  29189. */
  29190. hideLoadingUI: () => void;
  29191. /**
  29192. * Gets or sets the color to use for the background
  29193. */
  29194. loadingUIBackgroundColor: string;
  29195. /**
  29196. * Gets or sets the text to display while loading
  29197. */
  29198. loadingUIText: string;
  29199. }
  29200. /**
  29201. * Class used for the default loading screen
  29202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29203. */
  29204. export class DefaultLoadingScreen implements ILoadingScreen {
  29205. private _renderingCanvas;
  29206. private _loadingText;
  29207. private _loadingDivBackgroundColor;
  29208. private _loadingDiv;
  29209. private _loadingTextDiv;
  29210. /** Gets or sets the logo url to use for the default loading screen */
  29211. static DefaultLogoUrl: string;
  29212. /** Gets or sets the spinner url to use for the default loading screen */
  29213. static DefaultSpinnerUrl: string;
  29214. /**
  29215. * Creates a new default loading screen
  29216. * @param _renderingCanvas defines the canvas used to render the scene
  29217. * @param _loadingText defines the default text to display
  29218. * @param _loadingDivBackgroundColor defines the default background color
  29219. */
  29220. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29221. /**
  29222. * Function called to display the loading screen
  29223. */
  29224. displayLoadingUI(): void;
  29225. /**
  29226. * Function called to hide the loading screen
  29227. */
  29228. hideLoadingUI(): void;
  29229. /**
  29230. * Gets or sets the text to display while loading
  29231. */
  29232. loadingUIText: string;
  29233. /**
  29234. * Gets or sets the color to use for the background
  29235. */
  29236. loadingUIBackgroundColor: string;
  29237. private _resizeLoadingUI;
  29238. }
  29239. }
  29240. declare module BABYLON {
  29241. /** @hidden */
  29242. export class WebGLPipelineContext implements IPipelineContext {
  29243. engine: Engine;
  29244. program: Nullable<WebGLProgram>;
  29245. context?: WebGLRenderingContext;
  29246. vertexShader?: WebGLShader;
  29247. fragmentShader?: WebGLShader;
  29248. isParallelCompiled: boolean;
  29249. onCompiled?: () => void;
  29250. transformFeedback?: WebGLTransformFeedback | null;
  29251. readonly isAsync: boolean;
  29252. readonly isReady: boolean;
  29253. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29254. }
  29255. }
  29256. declare module BABYLON {
  29257. /** @hidden */
  29258. export class WebGLDataBuffer extends DataBuffer {
  29259. private _buffer;
  29260. constructor(resource: WebGLBuffer);
  29261. readonly underlyingResource: any;
  29262. }
  29263. }
  29264. declare module BABYLON {
  29265. /** @hidden */
  29266. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29267. attributeProcessor(attribute: string): string;
  29268. varyingProcessor(varying: string, isFragment: boolean): string;
  29269. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29270. }
  29271. }
  29272. declare module BABYLON {
  29273. /**
  29274. * This class is used to track a performance counter which is number based.
  29275. * The user has access to many properties which give statistics of different nature.
  29276. *
  29277. * The implementer can track two kinds of Performance Counter: time and count.
  29278. * 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.
  29279. * 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.
  29280. */
  29281. export class PerfCounter {
  29282. /**
  29283. * Gets or sets a global boolean to turn on and off all the counters
  29284. */
  29285. static Enabled: boolean;
  29286. /**
  29287. * Returns the smallest value ever
  29288. */
  29289. readonly min: number;
  29290. /**
  29291. * Returns the biggest value ever
  29292. */
  29293. readonly max: number;
  29294. /**
  29295. * Returns the average value since the performance counter is running
  29296. */
  29297. readonly average: number;
  29298. /**
  29299. * Returns the average value of the last second the counter was monitored
  29300. */
  29301. readonly lastSecAverage: number;
  29302. /**
  29303. * Returns the current value
  29304. */
  29305. readonly current: number;
  29306. /**
  29307. * Gets the accumulated total
  29308. */
  29309. readonly total: number;
  29310. /**
  29311. * Gets the total value count
  29312. */
  29313. readonly count: number;
  29314. /**
  29315. * Creates a new counter
  29316. */
  29317. constructor();
  29318. /**
  29319. * Call this method to start monitoring a new frame.
  29320. * 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.
  29321. */
  29322. fetchNewFrame(): void;
  29323. /**
  29324. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29325. * @param newCount the count value to add to the monitored count
  29326. * @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.
  29327. */
  29328. addCount(newCount: number, fetchResult: boolean): void;
  29329. /**
  29330. * Start monitoring this performance counter
  29331. */
  29332. beginMonitoring(): void;
  29333. /**
  29334. * Compute the time lapsed since the previous beginMonitoring() call.
  29335. * @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
  29336. */
  29337. endMonitoring(newFrame?: boolean): void;
  29338. private _fetchResult;
  29339. private _startMonitoringTime;
  29340. private _min;
  29341. private _max;
  29342. private _average;
  29343. private _current;
  29344. private _totalValueCount;
  29345. private _totalAccumulated;
  29346. private _lastSecAverage;
  29347. private _lastSecAccumulated;
  29348. private _lastSecTime;
  29349. private _lastSecValueCount;
  29350. }
  29351. }
  29352. declare module BABYLON {
  29353. /**
  29354. * Interface for any object that can request an animation frame
  29355. */
  29356. export interface ICustomAnimationFrameRequester {
  29357. /**
  29358. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29359. */
  29360. renderFunction?: Function;
  29361. /**
  29362. * Called to request the next frame to render to
  29363. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29364. */
  29365. requestAnimationFrame: Function;
  29366. /**
  29367. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29368. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29369. */
  29370. requestID?: number;
  29371. }
  29372. }
  29373. declare module BABYLON {
  29374. /**
  29375. * Settings for finer control over video usage
  29376. */
  29377. export interface VideoTextureSettings {
  29378. /**
  29379. * Applies `autoplay` to video, if specified
  29380. */
  29381. autoPlay?: boolean;
  29382. /**
  29383. * Applies `loop` to video, if specified
  29384. */
  29385. loop?: boolean;
  29386. /**
  29387. * Automatically updates internal texture from video at every frame in the render loop
  29388. */
  29389. autoUpdateTexture: boolean;
  29390. /**
  29391. * Image src displayed during the video loading or until the user interacts with the video.
  29392. */
  29393. poster?: string;
  29394. }
  29395. /**
  29396. * If you want to display a video in your scene, this is the special texture for that.
  29397. * This special texture works similar to other textures, with the exception of a few parameters.
  29398. * @see https://doc.babylonjs.com/how_to/video_texture
  29399. */
  29400. export class VideoTexture extends Texture {
  29401. /**
  29402. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29403. */
  29404. readonly autoUpdateTexture: boolean;
  29405. /**
  29406. * The video instance used by the texture internally
  29407. */
  29408. readonly video: HTMLVideoElement;
  29409. private _onUserActionRequestedObservable;
  29410. /**
  29411. * Event triggerd when a dom action is required by the user to play the video.
  29412. * This happens due to recent changes in browser policies preventing video to auto start.
  29413. */
  29414. readonly onUserActionRequestedObservable: Observable<Texture>;
  29415. private _generateMipMaps;
  29416. private _engine;
  29417. private _stillImageCaptured;
  29418. private _displayingPosterTexture;
  29419. private _settings;
  29420. private _createInternalTextureOnEvent;
  29421. /**
  29422. * Creates a video texture.
  29423. * If you want to display a video in your scene, this is the special texture for that.
  29424. * This special texture works similar to other textures, with the exception of a few parameters.
  29425. * @see https://doc.babylonjs.com/how_to/video_texture
  29426. * @param name optional name, will detect from video source, if not defined
  29427. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29428. * @param scene is obviously the current scene.
  29429. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29430. * @param invertY is false by default but can be used to invert video on Y axis
  29431. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29432. * @param settings allows finer control over video usage
  29433. */
  29434. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29435. private _getName;
  29436. private _getVideo;
  29437. private _createInternalTexture;
  29438. private reset;
  29439. /**
  29440. * @hidden Internal method to initiate `update`.
  29441. */
  29442. _rebuild(): void;
  29443. /**
  29444. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29445. */
  29446. update(): void;
  29447. /**
  29448. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29449. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29450. */
  29451. updateTexture(isVisible: boolean): void;
  29452. protected _updateInternalTexture: () => void;
  29453. /**
  29454. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29455. * @param url New url.
  29456. */
  29457. updateURL(url: string): void;
  29458. /**
  29459. * Dispose the texture and release its associated resources.
  29460. */
  29461. dispose(): void;
  29462. /**
  29463. * Creates a video texture straight from a stream.
  29464. * @param scene Define the scene the texture should be created in
  29465. * @param stream Define the stream the texture should be created from
  29466. * @returns The created video texture as a promise
  29467. */
  29468. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29469. /**
  29470. * Creates a video texture straight from your WebCam video feed.
  29471. * @param scene Define the scene the texture should be created in
  29472. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29473. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29474. * @returns The created video texture as a promise
  29475. */
  29476. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29477. minWidth: number;
  29478. maxWidth: number;
  29479. minHeight: number;
  29480. maxHeight: number;
  29481. deviceId: string;
  29482. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29483. /**
  29484. * Creates a video texture straight from your WebCam video feed.
  29485. * @param scene Define the scene the texture should be created in
  29486. * @param onReady Define a callback to triggered once the texture will be ready
  29487. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29488. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29489. */
  29490. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29491. minWidth: number;
  29492. maxWidth: number;
  29493. minHeight: number;
  29494. maxHeight: number;
  29495. deviceId: string;
  29496. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29497. }
  29498. }
  29499. declare module BABYLON {
  29500. /**
  29501. * Defines the interface used by objects containing a viewport (like a camera)
  29502. */
  29503. interface IViewportOwnerLike {
  29504. /**
  29505. * Gets or sets the viewport
  29506. */
  29507. viewport: IViewportLike;
  29508. }
  29509. /**
  29510. * Interface for attribute information associated with buffer instanciation
  29511. */
  29512. export class InstancingAttributeInfo {
  29513. /**
  29514. * Index/offset of the attribute in the vertex shader
  29515. */
  29516. index: number;
  29517. /**
  29518. * size of the attribute, 1, 2, 3 or 4
  29519. */
  29520. attributeSize: number;
  29521. /**
  29522. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29523. * default is FLOAT
  29524. */
  29525. attribyteType: number;
  29526. /**
  29527. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29528. */
  29529. normalized: boolean;
  29530. /**
  29531. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29532. */
  29533. offset: number;
  29534. /**
  29535. * Name of the GLSL attribute, for debugging purpose only
  29536. */
  29537. attributeName: string;
  29538. }
  29539. /**
  29540. * Define options used to create a depth texture
  29541. */
  29542. export class DepthTextureCreationOptions {
  29543. /** Specifies whether or not a stencil should be allocated in the texture */
  29544. generateStencil?: boolean;
  29545. /** Specifies whether or not bilinear filtering is enable on the texture */
  29546. bilinearFiltering?: boolean;
  29547. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29548. comparisonFunction?: number;
  29549. /** Specifies if the created texture is a cube texture */
  29550. isCube?: boolean;
  29551. }
  29552. /**
  29553. * Class used to describe the capabilities of the engine relatively to the current browser
  29554. */
  29555. export class EngineCapabilities {
  29556. /** Maximum textures units per fragment shader */
  29557. maxTexturesImageUnits: number;
  29558. /** Maximum texture units per vertex shader */
  29559. maxVertexTextureImageUnits: number;
  29560. /** Maximum textures units in the entire pipeline */
  29561. maxCombinedTexturesImageUnits: number;
  29562. /** Maximum texture size */
  29563. maxTextureSize: number;
  29564. /** Maximum cube texture size */
  29565. maxCubemapTextureSize: number;
  29566. /** Maximum render texture size */
  29567. maxRenderTextureSize: number;
  29568. /** Maximum number of vertex attributes */
  29569. maxVertexAttribs: number;
  29570. /** Maximum number of varyings */
  29571. maxVaryingVectors: number;
  29572. /** Maximum number of uniforms per vertex shader */
  29573. maxVertexUniformVectors: number;
  29574. /** Maximum number of uniforms per fragment shader */
  29575. maxFragmentUniformVectors: number;
  29576. /** Defines if standard derivates (dx/dy) are supported */
  29577. standardDerivatives: boolean;
  29578. /** Defines if s3tc texture compression is supported */
  29579. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29580. /** Defines if pvrtc texture compression is supported */
  29581. pvrtc: any;
  29582. /** Defines if etc1 texture compression is supported */
  29583. etc1: any;
  29584. /** Defines if etc2 texture compression is supported */
  29585. etc2: any;
  29586. /** Defines if astc texture compression is supported */
  29587. astc: any;
  29588. /** Defines if float textures are supported */
  29589. textureFloat: boolean;
  29590. /** Defines if vertex array objects are supported */
  29591. vertexArrayObject: boolean;
  29592. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29593. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29594. /** Gets the maximum level of anisotropy supported */
  29595. maxAnisotropy: number;
  29596. /** Defines if instancing is supported */
  29597. instancedArrays: boolean;
  29598. /** Defines if 32 bits indices are supported */
  29599. uintIndices: boolean;
  29600. /** Defines if high precision shaders are supported */
  29601. highPrecisionShaderSupported: boolean;
  29602. /** Defines if depth reading in the fragment shader is supported */
  29603. fragmentDepthSupported: boolean;
  29604. /** Defines if float texture linear filtering is supported*/
  29605. textureFloatLinearFiltering: boolean;
  29606. /** Defines if rendering to float textures is supported */
  29607. textureFloatRender: boolean;
  29608. /** Defines if half float textures are supported*/
  29609. textureHalfFloat: boolean;
  29610. /** Defines if half float texture linear filtering is supported*/
  29611. textureHalfFloatLinearFiltering: boolean;
  29612. /** Defines if rendering to half float textures is supported */
  29613. textureHalfFloatRender: boolean;
  29614. /** Defines if textureLOD shader command is supported */
  29615. textureLOD: boolean;
  29616. /** Defines if draw buffers extension is supported */
  29617. drawBuffersExtension: boolean;
  29618. /** Defines if depth textures are supported */
  29619. depthTextureExtension: boolean;
  29620. /** Defines if float color buffer are supported */
  29621. colorBufferFloat: boolean;
  29622. /** Gets disjoint timer query extension (null if not supported) */
  29623. timerQuery: EXT_disjoint_timer_query;
  29624. /** Defines if timestamp can be used with timer query */
  29625. canUseTimestampForTimerQuery: boolean;
  29626. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29627. multiview: any;
  29628. /** Function used to let the system compiles shaders in background */
  29629. parallelShaderCompile: {
  29630. COMPLETION_STATUS_KHR: number;
  29631. };
  29632. /** Max number of texture samples for MSAA */
  29633. maxMSAASamples: number;
  29634. }
  29635. /** Interface defining initialization parameters for Engine class */
  29636. export interface EngineOptions extends WebGLContextAttributes {
  29637. /**
  29638. * Defines if the engine should no exceed a specified device ratio
  29639. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29640. */
  29641. limitDeviceRatio?: number;
  29642. /**
  29643. * Defines if webvr should be enabled automatically
  29644. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29645. */
  29646. autoEnableWebVR?: boolean;
  29647. /**
  29648. * Defines if webgl2 should be turned off even if supported
  29649. * @see http://doc.babylonjs.com/features/webgl2
  29650. */
  29651. disableWebGL2Support?: boolean;
  29652. /**
  29653. * Defines if webaudio should be initialized as well
  29654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29655. */
  29656. audioEngine?: boolean;
  29657. /**
  29658. * Defines if animations should run using a deterministic lock step
  29659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29660. */
  29661. deterministicLockstep?: boolean;
  29662. /** Defines the maximum steps to use with deterministic lock step mode */
  29663. lockstepMaxSteps?: number;
  29664. /**
  29665. * Defines that engine should ignore context lost events
  29666. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29667. */
  29668. doNotHandleContextLost?: boolean;
  29669. /**
  29670. * Defines that engine should ignore modifying touch action attribute and style
  29671. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29672. */
  29673. doNotHandleTouchAction?: boolean;
  29674. /**
  29675. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29676. */
  29677. useHighPrecisionFloats?: boolean;
  29678. }
  29679. /**
  29680. * Defines the interface used by display changed events
  29681. */
  29682. export interface IDisplayChangedEventArgs {
  29683. /** Gets the vrDisplay object (if any) */
  29684. vrDisplay: Nullable<any>;
  29685. /** Gets a boolean indicating if webVR is supported */
  29686. vrSupported: boolean;
  29687. }
  29688. /**
  29689. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29690. */
  29691. export class Engine {
  29692. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29693. static ExceptionList: ({
  29694. key: string;
  29695. capture: string;
  29696. captureConstraint: number;
  29697. targets: string[];
  29698. } | {
  29699. key: string;
  29700. capture: null;
  29701. captureConstraint: null;
  29702. targets: string[];
  29703. })[];
  29704. /** Gets the list of created engines */
  29705. static readonly Instances: Engine[];
  29706. /**
  29707. * Gets the latest created engine
  29708. */
  29709. static readonly LastCreatedEngine: Nullable<Engine>;
  29710. /**
  29711. * Gets the latest created scene
  29712. */
  29713. static readonly LastCreatedScene: Nullable<Scene>;
  29714. /**
  29715. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29716. * @param flag defines which part of the materials must be marked as dirty
  29717. * @param predicate defines a predicate used to filter which materials should be affected
  29718. */
  29719. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29720. /** @hidden */
  29721. static _TextureLoaders: IInternalTextureLoader[];
  29722. /** Defines that alpha blending is disabled */
  29723. static readonly ALPHA_DISABLE: number;
  29724. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29725. static readonly ALPHA_ADD: number;
  29726. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29727. static readonly ALPHA_COMBINE: number;
  29728. /** Defines that alpha blending to DEST - SRC * DEST */
  29729. static readonly ALPHA_SUBTRACT: number;
  29730. /** Defines that alpha blending to SRC * DEST */
  29731. static readonly ALPHA_MULTIPLY: number;
  29732. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29733. static readonly ALPHA_MAXIMIZED: number;
  29734. /** Defines that alpha blending to SRC + DEST */
  29735. static readonly ALPHA_ONEONE: number;
  29736. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29737. static readonly ALPHA_PREMULTIPLIED: number;
  29738. /**
  29739. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29740. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29741. */
  29742. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29743. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29744. static readonly ALPHA_INTERPOLATE: number;
  29745. /**
  29746. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29747. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29748. */
  29749. static readonly ALPHA_SCREENMODE: number;
  29750. /** Defines that the ressource is not delayed*/
  29751. static readonly DELAYLOADSTATE_NONE: number;
  29752. /** Defines that the ressource was successfully delay loaded */
  29753. static readonly DELAYLOADSTATE_LOADED: number;
  29754. /** Defines that the ressource is currently delay loading */
  29755. static readonly DELAYLOADSTATE_LOADING: number;
  29756. /** Defines that the ressource is delayed and has not started loading */
  29757. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29758. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29759. static readonly NEVER: number;
  29760. /** 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 */
  29761. static readonly ALWAYS: number;
  29762. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29763. static readonly LESS: number;
  29764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29765. static readonly EQUAL: number;
  29766. /** 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 */
  29767. static readonly LEQUAL: number;
  29768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29769. static readonly GREATER: number;
  29770. /** 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 */
  29771. static readonly GEQUAL: number;
  29772. /** 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 */
  29773. static readonly NOTEQUAL: number;
  29774. /** Passed to stencilOperation to specify that stencil value must be kept */
  29775. static readonly KEEP: number;
  29776. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29777. static readonly REPLACE: number;
  29778. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29779. static readonly INCR: number;
  29780. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29781. static readonly DECR: number;
  29782. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29783. static readonly INVERT: number;
  29784. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29785. static readonly INCR_WRAP: number;
  29786. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29787. static readonly DECR_WRAP: number;
  29788. /** Texture is not repeating outside of 0..1 UVs */
  29789. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29790. /** Texture is repeating outside of 0..1 UVs */
  29791. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29792. /** Texture is repeating and mirrored */
  29793. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29794. /** ALPHA */
  29795. static readonly TEXTUREFORMAT_ALPHA: number;
  29796. /** LUMINANCE */
  29797. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29798. /** LUMINANCE_ALPHA */
  29799. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29800. /** RGB */
  29801. static readonly TEXTUREFORMAT_RGB: number;
  29802. /** RGBA */
  29803. static readonly TEXTUREFORMAT_RGBA: number;
  29804. /** RED */
  29805. static readonly TEXTUREFORMAT_RED: number;
  29806. /** RED (2nd reference) */
  29807. static readonly TEXTUREFORMAT_R: number;
  29808. /** RG */
  29809. static readonly TEXTUREFORMAT_RG: number;
  29810. /** RED_INTEGER */
  29811. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29812. /** RED_INTEGER (2nd reference) */
  29813. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29814. /** RG_INTEGER */
  29815. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29816. /** RGB_INTEGER */
  29817. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29818. /** RGBA_INTEGER */
  29819. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29820. /** UNSIGNED_BYTE */
  29821. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29822. /** UNSIGNED_BYTE (2nd reference) */
  29823. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29824. /** FLOAT */
  29825. static readonly TEXTURETYPE_FLOAT: number;
  29826. /** HALF_FLOAT */
  29827. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29828. /** BYTE */
  29829. static readonly TEXTURETYPE_BYTE: number;
  29830. /** SHORT */
  29831. static readonly TEXTURETYPE_SHORT: number;
  29832. /** UNSIGNED_SHORT */
  29833. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29834. /** INT */
  29835. static readonly TEXTURETYPE_INT: number;
  29836. /** UNSIGNED_INT */
  29837. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29838. /** UNSIGNED_SHORT_4_4_4_4 */
  29839. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29840. /** UNSIGNED_SHORT_5_5_5_1 */
  29841. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29842. /** UNSIGNED_SHORT_5_6_5 */
  29843. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29844. /** UNSIGNED_INT_2_10_10_10_REV */
  29845. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29846. /** UNSIGNED_INT_24_8 */
  29847. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29848. /** UNSIGNED_INT_10F_11F_11F_REV */
  29849. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29850. /** UNSIGNED_INT_5_9_9_9_REV */
  29851. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29852. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29853. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29854. /** nearest is mag = nearest and min = nearest and mip = linear */
  29855. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29856. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29857. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29858. /** Trilinear is mag = linear and min = linear and mip = linear */
  29859. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29860. /** nearest is mag = nearest and min = nearest and mip = linear */
  29861. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29863. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29864. /** Trilinear is mag = linear and min = linear and mip = linear */
  29865. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29866. /** mag = nearest and min = nearest and mip = nearest */
  29867. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29868. /** mag = nearest and min = linear and mip = nearest */
  29869. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29870. /** mag = nearest and min = linear and mip = linear */
  29871. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29872. /** mag = nearest and min = linear and mip = none */
  29873. static readonly TEXTURE_NEAREST_LINEAR: number;
  29874. /** mag = nearest and min = nearest and mip = none */
  29875. static readonly TEXTURE_NEAREST_NEAREST: number;
  29876. /** mag = linear and min = nearest and mip = nearest */
  29877. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29878. /** mag = linear and min = nearest and mip = linear */
  29879. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29880. /** mag = linear and min = linear and mip = none */
  29881. static readonly TEXTURE_LINEAR_LINEAR: number;
  29882. /** mag = linear and min = nearest and mip = none */
  29883. static readonly TEXTURE_LINEAR_NEAREST: number;
  29884. /** Explicit coordinates mode */
  29885. static readonly TEXTURE_EXPLICIT_MODE: number;
  29886. /** Spherical coordinates mode */
  29887. static readonly TEXTURE_SPHERICAL_MODE: number;
  29888. /** Planar coordinates mode */
  29889. static readonly TEXTURE_PLANAR_MODE: number;
  29890. /** Cubic coordinates mode */
  29891. static readonly TEXTURE_CUBIC_MODE: number;
  29892. /** Projection coordinates mode */
  29893. static readonly TEXTURE_PROJECTION_MODE: number;
  29894. /** Skybox coordinates mode */
  29895. static readonly TEXTURE_SKYBOX_MODE: number;
  29896. /** Inverse Cubic coordinates mode */
  29897. static readonly TEXTURE_INVCUBIC_MODE: number;
  29898. /** Equirectangular coordinates mode */
  29899. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29900. /** Equirectangular Fixed coordinates mode */
  29901. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29902. /** Equirectangular Fixed Mirrored coordinates mode */
  29903. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29904. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29905. static readonly SCALEMODE_FLOOR: number;
  29906. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29907. static readonly SCALEMODE_NEAREST: number;
  29908. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29909. static readonly SCALEMODE_CEILING: number;
  29910. /**
  29911. * Returns the current npm package of the sdk
  29912. */
  29913. static readonly NpmPackage: string;
  29914. /**
  29915. * Returns the current version of the framework
  29916. */
  29917. static readonly Version: string;
  29918. /**
  29919. * Returns a string describing the current engine
  29920. */
  29921. readonly description: string;
  29922. /**
  29923. * Gets or sets the epsilon value used by collision engine
  29924. */
  29925. static CollisionsEpsilon: number;
  29926. /**
  29927. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29928. */
  29929. static ShadersRepository: string;
  29930. /**
  29931. * Method called to create the default loading screen.
  29932. * This can be overriden in your own app.
  29933. * @param canvas The rendering canvas element
  29934. * @returns The loading screen
  29935. */
  29936. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29937. /**
  29938. * Method called to create the default rescale post process on each engine.
  29939. */
  29940. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29941. /** @hidden */
  29942. _shaderProcessor: IShaderProcessor;
  29943. /**
  29944. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29945. */
  29946. forcePOTTextures: boolean;
  29947. /**
  29948. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29949. */
  29950. isFullscreen: boolean;
  29951. /**
  29952. * Gets a boolean indicating if the pointer is currently locked
  29953. */
  29954. isPointerLock: boolean;
  29955. /**
  29956. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29957. */
  29958. cullBackFaces: boolean;
  29959. /**
  29960. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29961. */
  29962. renderEvenInBackground: boolean;
  29963. /**
  29964. * Gets or sets a boolean indicating that cache can be kept between frames
  29965. */
  29966. preventCacheWipeBetweenFrames: boolean;
  29967. /**
  29968. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29969. **/
  29970. enableOfflineSupport: boolean;
  29971. /**
  29972. * 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)
  29973. **/
  29974. disableManifestCheck: boolean;
  29975. /**
  29976. * Gets the list of created scenes
  29977. */
  29978. scenes: Scene[];
  29979. /**
  29980. * Event raised when a new scene is created
  29981. */
  29982. onNewSceneAddedObservable: Observable<Scene>;
  29983. /**
  29984. * Gets the list of created postprocesses
  29985. */
  29986. postProcesses: PostProcess[];
  29987. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29988. validateShaderPrograms: boolean;
  29989. /**
  29990. * Observable event triggered each time the rendering canvas is resized
  29991. */
  29992. onResizeObservable: Observable<Engine>;
  29993. /**
  29994. * Observable event triggered each time the canvas loses focus
  29995. */
  29996. onCanvasBlurObservable: Observable<Engine>;
  29997. /**
  29998. * Observable event triggered each time the canvas gains focus
  29999. */
  30000. onCanvasFocusObservable: Observable<Engine>;
  30001. /**
  30002. * Observable event triggered each time the canvas receives pointerout event
  30003. */
  30004. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30005. /**
  30006. * Observable event triggered before each texture is initialized
  30007. */
  30008. onBeforeTextureInitObservable: Observable<Texture>;
  30009. /**
  30010. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30011. */
  30012. disableUniformBuffers: boolean;
  30013. /** @hidden */
  30014. _uniformBuffers: UniformBuffer[];
  30015. /**
  30016. * Gets a boolean indicating that the engine supports uniform buffers
  30017. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30018. */
  30019. readonly supportsUniformBuffers: boolean;
  30020. /**
  30021. * Observable raised when the engine begins a new frame
  30022. */
  30023. onBeginFrameObservable: Observable<Engine>;
  30024. /**
  30025. * If set, will be used to request the next animation frame for the render loop
  30026. */
  30027. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30028. /**
  30029. * Observable raised when the engine ends the current frame
  30030. */
  30031. onEndFrameObservable: Observable<Engine>;
  30032. /**
  30033. * Observable raised when the engine is about to compile a shader
  30034. */
  30035. onBeforeShaderCompilationObservable: Observable<Engine>;
  30036. /**
  30037. * Observable raised when the engine has jsut compiled a shader
  30038. */
  30039. onAfterShaderCompilationObservable: Observable<Engine>;
  30040. /** @hidden */
  30041. _gl: WebGLRenderingContext;
  30042. private _renderingCanvas;
  30043. private _windowIsBackground;
  30044. private _webGLVersion;
  30045. protected _highPrecisionShadersAllowed: boolean;
  30046. /** @hidden */
  30047. readonly _shouldUseHighPrecisionShader: boolean;
  30048. /**
  30049. * Gets a boolean indicating that only power of 2 textures are supported
  30050. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30051. */
  30052. readonly needPOTTextures: boolean;
  30053. /** @hidden */
  30054. _badOS: boolean;
  30055. /** @hidden */
  30056. _badDesktopOS: boolean;
  30057. /**
  30058. * Gets the audio engine
  30059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30060. * @ignorenaming
  30061. */
  30062. static audioEngine: IAudioEngine;
  30063. /**
  30064. * Default AudioEngine factory responsible of creating the Audio Engine.
  30065. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30066. */
  30067. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30068. /**
  30069. * Default offline support factory responsible of creating a tool used to store data locally.
  30070. * By default, this will create a Database object if the workload has been embedded.
  30071. */
  30072. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30073. private _onFocus;
  30074. private _onBlur;
  30075. private _onCanvasPointerOut;
  30076. private _onCanvasBlur;
  30077. private _onCanvasFocus;
  30078. private _onFullscreenChange;
  30079. private _onPointerLockChange;
  30080. private _hardwareScalingLevel;
  30081. /** @hidden */
  30082. _caps: EngineCapabilities;
  30083. private _pointerLockRequested;
  30084. private _isStencilEnable;
  30085. private _colorWrite;
  30086. private _loadingScreen;
  30087. /** @hidden */
  30088. _drawCalls: PerfCounter;
  30089. private _glVersion;
  30090. private _glRenderer;
  30091. private _glVendor;
  30092. private _videoTextureSupported;
  30093. private _renderingQueueLaunched;
  30094. private _activeRenderLoops;
  30095. private _deterministicLockstep;
  30096. private _lockstepMaxSteps;
  30097. /**
  30098. * Observable signaled when a context lost event is raised
  30099. */
  30100. onContextLostObservable: Observable<Engine>;
  30101. /**
  30102. * Observable signaled when a context restored event is raised
  30103. */
  30104. onContextRestoredObservable: Observable<Engine>;
  30105. private _onContextLost;
  30106. private _onContextRestored;
  30107. private _contextWasLost;
  30108. /** @hidden */
  30109. _doNotHandleContextLost: boolean;
  30110. /**
  30111. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30113. */
  30114. doNotHandleContextLost: boolean;
  30115. private _performanceMonitor;
  30116. private _fps;
  30117. private _deltaTime;
  30118. /**
  30119. * Turn this value on if you want to pause FPS computation when in background
  30120. */
  30121. disablePerformanceMonitorInBackground: boolean;
  30122. /**
  30123. * Gets the performance monitor attached to this engine
  30124. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30125. */
  30126. readonly performanceMonitor: PerformanceMonitor;
  30127. /**
  30128. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30129. */
  30130. disableVertexArrayObjects: boolean;
  30131. /** @hidden */
  30132. protected _depthCullingState: _DepthCullingState;
  30133. /** @hidden */
  30134. protected _stencilState: _StencilState;
  30135. /** @hidden */
  30136. protected _alphaState: _AlphaState;
  30137. /** @hidden */
  30138. protected _alphaMode: number;
  30139. /** @hidden */
  30140. _internalTexturesCache: InternalTexture[];
  30141. /** @hidden */
  30142. protected _activeChannel: number;
  30143. private _currentTextureChannel;
  30144. /** @hidden */
  30145. protected _boundTexturesCache: {
  30146. [key: string]: Nullable<InternalTexture>;
  30147. };
  30148. /** @hidden */
  30149. protected _currentEffect: Nullable<Effect>;
  30150. /** @hidden */
  30151. protected _currentProgram: Nullable<WebGLProgram>;
  30152. private _compiledEffects;
  30153. private _vertexAttribArraysEnabled;
  30154. /** @hidden */
  30155. protected _cachedViewport: Nullable<IViewportLike>;
  30156. private _cachedVertexArrayObject;
  30157. /** @hidden */
  30158. protected _cachedVertexBuffers: any;
  30159. /** @hidden */
  30160. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30161. /** @hidden */
  30162. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30163. /** @hidden */
  30164. _currentRenderTarget: Nullable<InternalTexture>;
  30165. private _uintIndicesCurrentlySet;
  30166. private _currentBoundBuffer;
  30167. /** @hidden */
  30168. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30169. private _currentBufferPointers;
  30170. private _currentInstanceLocations;
  30171. private _currentInstanceBuffers;
  30172. private _textureUnits;
  30173. /** @hidden */
  30174. _workingCanvas: Nullable<HTMLCanvasElement>;
  30175. /** @hidden */
  30176. _workingContext: Nullable<CanvasRenderingContext2D>;
  30177. private _rescalePostProcess;
  30178. private _dummyFramebuffer;
  30179. private _externalData;
  30180. /** @hidden */
  30181. _bindedRenderFunction: any;
  30182. private _vaoRecordInProgress;
  30183. private _mustWipeVertexAttributes;
  30184. private _emptyTexture;
  30185. private _emptyCubeTexture;
  30186. private _emptyTexture3D;
  30187. /** @hidden */
  30188. _frameHandler: number;
  30189. private _nextFreeTextureSlots;
  30190. private _maxSimultaneousTextures;
  30191. private _activeRequests;
  30192. private _texturesSupported;
  30193. /** @hidden */
  30194. _textureFormatInUse: Nullable<string>;
  30195. /**
  30196. * Gets the list of texture formats supported
  30197. */
  30198. readonly texturesSupported: Array<string>;
  30199. /**
  30200. * Gets the list of texture formats in use
  30201. */
  30202. readonly textureFormatInUse: Nullable<string>;
  30203. /**
  30204. * Gets the current viewport
  30205. */
  30206. readonly currentViewport: Nullable<IViewportLike>;
  30207. /**
  30208. * Gets the default empty texture
  30209. */
  30210. readonly emptyTexture: InternalTexture;
  30211. /**
  30212. * Gets the default empty 3D texture
  30213. */
  30214. readonly emptyTexture3D: InternalTexture;
  30215. /**
  30216. * Gets the default empty cube texture
  30217. */
  30218. readonly emptyCubeTexture: InternalTexture;
  30219. /**
  30220. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30221. */
  30222. readonly premultipliedAlpha: boolean;
  30223. /**
  30224. * Creates a new engine
  30225. * @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
  30226. * @param antialias defines enable antialiasing (default: false)
  30227. * @param options defines further options to be sent to the getContext() function
  30228. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30229. */
  30230. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30231. /**
  30232. * Initializes a webVR display and starts listening to display change events
  30233. * The onVRDisplayChangedObservable will be notified upon these changes
  30234. * @returns The onVRDisplayChangedObservable
  30235. */
  30236. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30237. /** @hidden */
  30238. _prepareVRComponent(): void;
  30239. /** @hidden */
  30240. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30241. /** @hidden */
  30242. _submitVRFrame(): void;
  30243. /**
  30244. * Call this function to leave webVR mode
  30245. * Will do nothing if webVR is not supported or if there is no webVR device
  30246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30247. */
  30248. disableVR(): void;
  30249. /**
  30250. * Gets a boolean indicating that the system is in VR mode and is presenting
  30251. * @returns true if VR mode is engaged
  30252. */
  30253. isVRPresenting(): boolean;
  30254. /** @hidden */
  30255. _requestVRFrame(): void;
  30256. private _disableTouchAction;
  30257. private _rebuildInternalTextures;
  30258. private _rebuildEffects;
  30259. /**
  30260. * Gets a boolean indicating if all created effects are ready
  30261. * @returns true if all effects are ready
  30262. */
  30263. areAllEffectsReady(): boolean;
  30264. private _rebuildBuffers;
  30265. private _initGLContext;
  30266. /**
  30267. * Gets version of the current webGL context
  30268. */
  30269. readonly webGLVersion: number;
  30270. /**
  30271. * Gets a string idenfifying the name of the class
  30272. * @returns "Engine" string
  30273. */
  30274. getClassName(): string;
  30275. /**
  30276. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30277. */
  30278. readonly isStencilEnable: boolean;
  30279. /** @hidden */
  30280. _prepareWorkingCanvas(): void;
  30281. /**
  30282. * Reset the texture cache to empty state
  30283. */
  30284. resetTextureCache(): void;
  30285. /**
  30286. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30287. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30288. * @returns true if engine is in deterministic lock step mode
  30289. */
  30290. isDeterministicLockStep(): boolean;
  30291. /**
  30292. * Gets the max steps when engine is running in deterministic lock step
  30293. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30294. * @returns the max steps
  30295. */
  30296. getLockstepMaxSteps(): number;
  30297. /**
  30298. * Gets an object containing information about the current webGL context
  30299. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30300. */
  30301. getGlInfo(): {
  30302. vendor: string;
  30303. renderer: string;
  30304. version: string;
  30305. };
  30306. /**
  30307. * Gets current aspect ratio
  30308. * @param viewportOwner defines the camera to use to get the aspect ratio
  30309. * @param useScreen defines if screen size must be used (or the current render target if any)
  30310. * @returns a number defining the aspect ratio
  30311. */
  30312. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30313. /**
  30314. * Gets current screen aspect ratio
  30315. * @returns a number defining the aspect ratio
  30316. */
  30317. getScreenAspectRatio(): number;
  30318. /**
  30319. * Gets the current render width
  30320. * @param useScreen defines if screen size must be used (or the current render target if any)
  30321. * @returns a number defining the current render width
  30322. */
  30323. getRenderWidth(useScreen?: boolean): number;
  30324. /**
  30325. * Gets the current render height
  30326. * @param useScreen defines if screen size must be used (or the current render target if any)
  30327. * @returns a number defining the current render height
  30328. */
  30329. getRenderHeight(useScreen?: boolean): number;
  30330. /**
  30331. * Gets the HTML canvas attached with the current webGL context
  30332. * @returns a HTML canvas
  30333. */
  30334. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30335. /**
  30336. * Gets host window
  30337. * @returns the host window object
  30338. */
  30339. getHostWindow(): Window;
  30340. /**
  30341. * Gets host document
  30342. * @returns the host document object
  30343. */
  30344. getHostDocument(): Document;
  30345. /**
  30346. * Gets the client rect of the HTML canvas attached with the current webGL context
  30347. * @returns a client rectanglee
  30348. */
  30349. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30350. /**
  30351. * Defines the hardware scaling level.
  30352. * By default the hardware scaling level is computed from the window device ratio.
  30353. * 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.
  30354. * @param level defines the level to use
  30355. */
  30356. setHardwareScalingLevel(level: number): void;
  30357. /**
  30358. * Gets the current hardware scaling level.
  30359. * By default the hardware scaling level is computed from the window device ratio.
  30360. * 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.
  30361. * @returns a number indicating the current hardware scaling level
  30362. */
  30363. getHardwareScalingLevel(): number;
  30364. /**
  30365. * Gets the list of loaded textures
  30366. * @returns an array containing all loaded textures
  30367. */
  30368. getLoadedTexturesCache(): InternalTexture[];
  30369. /**
  30370. * Gets the object containing all engine capabilities
  30371. * @returns the EngineCapabilities object
  30372. */
  30373. getCaps(): EngineCapabilities;
  30374. /**
  30375. * Gets the current depth function
  30376. * @returns a number defining the depth function
  30377. */
  30378. getDepthFunction(): Nullable<number>;
  30379. /**
  30380. * Sets the current depth function
  30381. * @param depthFunc defines the function to use
  30382. */
  30383. setDepthFunction(depthFunc: number): void;
  30384. /**
  30385. * Sets the current depth function to GREATER
  30386. */
  30387. setDepthFunctionToGreater(): void;
  30388. /**
  30389. * Sets the current depth function to GEQUAL
  30390. */
  30391. setDepthFunctionToGreaterOrEqual(): void;
  30392. /**
  30393. * Sets the current depth function to LESS
  30394. */
  30395. setDepthFunctionToLess(): void;
  30396. private _cachedStencilBuffer;
  30397. private _cachedStencilFunction;
  30398. private _cachedStencilMask;
  30399. private _cachedStencilOperationPass;
  30400. private _cachedStencilOperationFail;
  30401. private _cachedStencilOperationDepthFail;
  30402. private _cachedStencilReference;
  30403. /**
  30404. * Caches the the state of the stencil buffer
  30405. */
  30406. cacheStencilState(): void;
  30407. /**
  30408. * Restores the state of the stencil buffer
  30409. */
  30410. restoreStencilState(): void;
  30411. /**
  30412. * Sets the current depth function to LEQUAL
  30413. */
  30414. setDepthFunctionToLessOrEqual(): void;
  30415. /**
  30416. * Gets a boolean indicating if stencil buffer is enabled
  30417. * @returns the current stencil buffer state
  30418. */
  30419. getStencilBuffer(): boolean;
  30420. /**
  30421. * Enable or disable the stencil buffer
  30422. * @param enable defines if the stencil buffer must be enabled or disabled
  30423. */
  30424. setStencilBuffer(enable: boolean): void;
  30425. /**
  30426. * Gets the current stencil mask
  30427. * @returns a number defining the new stencil mask to use
  30428. */
  30429. getStencilMask(): number;
  30430. /**
  30431. * Sets the current stencil mask
  30432. * @param mask defines the new stencil mask to use
  30433. */
  30434. setStencilMask(mask: number): void;
  30435. /**
  30436. * Gets the current stencil function
  30437. * @returns a number defining the stencil function to use
  30438. */
  30439. getStencilFunction(): number;
  30440. /**
  30441. * Gets the current stencil reference value
  30442. * @returns a number defining the stencil reference value to use
  30443. */
  30444. getStencilFunctionReference(): number;
  30445. /**
  30446. * Gets the current stencil mask
  30447. * @returns a number defining the stencil mask to use
  30448. */
  30449. getStencilFunctionMask(): number;
  30450. /**
  30451. * Sets the current stencil function
  30452. * @param stencilFunc defines the new stencil function to use
  30453. */
  30454. setStencilFunction(stencilFunc: number): void;
  30455. /**
  30456. * Sets the current stencil reference
  30457. * @param reference defines the new stencil reference to use
  30458. */
  30459. setStencilFunctionReference(reference: number): void;
  30460. /**
  30461. * Sets the current stencil mask
  30462. * @param mask defines the new stencil mask to use
  30463. */
  30464. setStencilFunctionMask(mask: number): void;
  30465. /**
  30466. * Gets the current stencil operation when stencil fails
  30467. * @returns a number defining stencil operation to use when stencil fails
  30468. */
  30469. getStencilOperationFail(): number;
  30470. /**
  30471. * Gets the current stencil operation when depth fails
  30472. * @returns a number defining stencil operation to use when depth fails
  30473. */
  30474. getStencilOperationDepthFail(): number;
  30475. /**
  30476. * Gets the current stencil operation when stencil passes
  30477. * @returns a number defining stencil operation to use when stencil passes
  30478. */
  30479. getStencilOperationPass(): number;
  30480. /**
  30481. * Sets the stencil operation to use when stencil fails
  30482. * @param operation defines the stencil operation to use when stencil fails
  30483. */
  30484. setStencilOperationFail(operation: number): void;
  30485. /**
  30486. * Sets the stencil operation to use when depth fails
  30487. * @param operation defines the stencil operation to use when depth fails
  30488. */
  30489. setStencilOperationDepthFail(operation: number): void;
  30490. /**
  30491. * Sets the stencil operation to use when stencil passes
  30492. * @param operation defines the stencil operation to use when stencil passes
  30493. */
  30494. setStencilOperationPass(operation: number): void;
  30495. /**
  30496. * Sets a boolean indicating if the dithering state is enabled or disabled
  30497. * @param value defines the dithering state
  30498. */
  30499. setDitheringState(value: boolean): void;
  30500. /**
  30501. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30502. * @param value defines the rasterizer state
  30503. */
  30504. setRasterizerState(value: boolean): void;
  30505. /**
  30506. * stop executing a render loop function and remove it from the execution array
  30507. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30508. */
  30509. stopRenderLoop(renderFunction?: () => void): void;
  30510. /** @hidden */
  30511. _renderLoop(): void;
  30512. /**
  30513. * Register and execute a render loop. The engine can have more than one render function
  30514. * @param renderFunction defines the function to continuously execute
  30515. */
  30516. runRenderLoop(renderFunction: () => void): void;
  30517. /**
  30518. * Toggle full screen mode
  30519. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30520. */
  30521. switchFullscreen(requestPointerLock: boolean): void;
  30522. /**
  30523. * Enters full screen mode
  30524. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30525. */
  30526. enterFullscreen(requestPointerLock: boolean): void;
  30527. /**
  30528. * Exits full screen mode
  30529. */
  30530. exitFullscreen(): void;
  30531. /**
  30532. * Enters Pointerlock mode
  30533. */
  30534. enterPointerlock(): void;
  30535. /**
  30536. * Exits Pointerlock mode
  30537. */
  30538. exitPointerlock(): void;
  30539. /**
  30540. * Clear the current render buffer or the current render target (if any is set up)
  30541. * @param color defines the color to use
  30542. * @param backBuffer defines if the back buffer must be cleared
  30543. * @param depth defines if the depth buffer must be cleared
  30544. * @param stencil defines if the stencil buffer must be cleared
  30545. */
  30546. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30547. /**
  30548. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30549. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30550. * @param y defines the y-coordinate of the corner of the clear rectangle
  30551. * @param width defines the width of the clear rectangle
  30552. * @param height defines the height of the clear rectangle
  30553. * @param clearColor defines the clear color
  30554. */
  30555. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30556. /**
  30557. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30558. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30559. * @param y defines the y-coordinate of the corner of the clear rectangle
  30560. * @param width defines the width of the clear rectangle
  30561. * @param height defines the height of the clear rectangle
  30562. */
  30563. enableScissor(x: number, y: number, width: number, height: number): void;
  30564. /**
  30565. * Disable previously set scissor test rectangle
  30566. */
  30567. disableScissor(): void;
  30568. private _viewportCached;
  30569. /** @hidden */
  30570. _viewport(x: number, y: number, width: number, height: number): void;
  30571. /**
  30572. * Set the WebGL's viewport
  30573. * @param viewport defines the viewport element to be used
  30574. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30575. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30576. */
  30577. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30578. /**
  30579. * Directly set the WebGL Viewport
  30580. * @param x defines the x coordinate of the viewport (in screen space)
  30581. * @param y defines the y coordinate of the viewport (in screen space)
  30582. * @param width defines the width of the viewport (in screen space)
  30583. * @param height defines the height of the viewport (in screen space)
  30584. * @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
  30585. */
  30586. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30587. /**
  30588. * Begin a new frame
  30589. */
  30590. beginFrame(): void;
  30591. /**
  30592. * Enf the current frame
  30593. */
  30594. endFrame(): void;
  30595. /**
  30596. * Resize the view according to the canvas' size
  30597. */
  30598. resize(): void;
  30599. /**
  30600. * Force a specific size of the canvas
  30601. * @param width defines the new canvas' width
  30602. * @param height defines the new canvas' height
  30603. */
  30604. setSize(width: number, height: number): void;
  30605. /**
  30606. * Binds the frame buffer to the specified texture.
  30607. * @param texture The texture to render to or null for the default canvas
  30608. * @param faceIndex The face of the texture to render to in case of cube texture
  30609. * @param requiredWidth The width of the target to render to
  30610. * @param requiredHeight The height of the target to render to
  30611. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30612. * @param depthStencilTexture The depth stencil texture to use to render
  30613. * @param lodLevel defines le lod level to bind to the frame buffer
  30614. */
  30615. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30616. /** @hidden */
  30617. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30618. /**
  30619. * Unbind the current render target texture from the webGL context
  30620. * @param texture defines the render target texture to unbind
  30621. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30622. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30623. */
  30624. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30625. /**
  30626. * Force the mipmap generation for the given render target texture
  30627. * @param texture defines the render target texture to use
  30628. */
  30629. generateMipMapsForCubemap(texture: InternalTexture): void;
  30630. /**
  30631. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30632. */
  30633. flushFramebuffer(): void;
  30634. /**
  30635. * Unbind the current render target and bind the default framebuffer
  30636. */
  30637. restoreDefaultFramebuffer(): void;
  30638. /**
  30639. * Create an uniform buffer
  30640. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30641. * @param elements defines the content of the uniform buffer
  30642. * @returns the webGL uniform buffer
  30643. */
  30644. createUniformBuffer(elements: FloatArray): DataBuffer;
  30645. /**
  30646. * Create a dynamic uniform buffer
  30647. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30648. * @param elements defines the content of the uniform buffer
  30649. * @returns the webGL uniform buffer
  30650. */
  30651. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30652. /**
  30653. * Update an existing uniform buffer
  30654. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30655. * @param uniformBuffer defines the target uniform buffer
  30656. * @param elements defines the content to update
  30657. * @param offset defines the offset in the uniform buffer where update should start
  30658. * @param count defines the size of the data to update
  30659. */
  30660. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30661. private _resetVertexBufferBinding;
  30662. /**
  30663. * Creates a vertex buffer
  30664. * @param data the data for the vertex buffer
  30665. * @returns the new WebGL static buffer
  30666. */
  30667. createVertexBuffer(data: DataArray): DataBuffer;
  30668. /**
  30669. * Creates a dynamic vertex buffer
  30670. * @param data the data for the dynamic vertex buffer
  30671. * @returns the new WebGL dynamic buffer
  30672. */
  30673. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30674. /**
  30675. * Update a dynamic index buffer
  30676. * @param indexBuffer defines the target index buffer
  30677. * @param indices defines the data to update
  30678. * @param offset defines the offset in the target index buffer where update should start
  30679. */
  30680. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30681. /**
  30682. * Updates a dynamic vertex buffer.
  30683. * @param vertexBuffer the vertex buffer to update
  30684. * @param data the data used to update the vertex buffer
  30685. * @param byteOffset the byte offset of the data
  30686. * @param byteLength the byte length of the data
  30687. */
  30688. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30689. private _resetIndexBufferBinding;
  30690. /**
  30691. * Creates a new index buffer
  30692. * @param indices defines the content of the index buffer
  30693. * @param updatable defines if the index buffer must be updatable
  30694. * @returns a new webGL buffer
  30695. */
  30696. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30697. /**
  30698. * Bind a webGL buffer to the webGL context
  30699. * @param buffer defines the buffer to bind
  30700. */
  30701. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30702. /**
  30703. * Bind an uniform buffer to the current webGL context
  30704. * @param buffer defines the buffer to bind
  30705. */
  30706. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30707. /**
  30708. * Bind a buffer to the current webGL context at a given location
  30709. * @param buffer defines the buffer to bind
  30710. * @param location defines the index where to bind the buffer
  30711. */
  30712. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30713. /**
  30714. * Bind a specific block at a given index in a specific shader program
  30715. * @param pipelineContext defines the pipeline context to use
  30716. * @param blockName defines the block name
  30717. * @param index defines the index where to bind the block
  30718. */
  30719. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30720. private bindIndexBuffer;
  30721. private bindBuffer;
  30722. /**
  30723. * update the bound buffer with the given data
  30724. * @param data defines the data to update
  30725. */
  30726. updateArrayBuffer(data: Float32Array): void;
  30727. private _vertexAttribPointer;
  30728. private _bindIndexBufferWithCache;
  30729. private _bindVertexBuffersAttributes;
  30730. /**
  30731. * Records a vertex array object
  30732. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30733. * @param vertexBuffers defines the list of vertex buffers to store
  30734. * @param indexBuffer defines the index buffer to store
  30735. * @param effect defines the effect to store
  30736. * @returns the new vertex array object
  30737. */
  30738. recordVertexArrayObject(vertexBuffers: {
  30739. [key: string]: VertexBuffer;
  30740. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30741. /**
  30742. * Bind a specific vertex array object
  30743. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30744. * @param vertexArrayObject defines the vertex array object to bind
  30745. * @param indexBuffer defines the index buffer to bind
  30746. */
  30747. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30748. /**
  30749. * Bind webGl buffers directly to the webGL context
  30750. * @param vertexBuffer defines the vertex buffer to bind
  30751. * @param indexBuffer defines the index buffer to bind
  30752. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30753. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30754. * @param effect defines the effect associated with the vertex buffer
  30755. */
  30756. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30757. private _unbindVertexArrayObject;
  30758. /**
  30759. * Bind a list of vertex buffers to the webGL context
  30760. * @param vertexBuffers defines the list of vertex buffers to bind
  30761. * @param indexBuffer defines the index buffer to bind
  30762. * @param effect defines the effect associated with the vertex buffers
  30763. */
  30764. bindBuffers(vertexBuffers: {
  30765. [key: string]: Nullable<VertexBuffer>;
  30766. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30767. /**
  30768. * Unbind all instance attributes
  30769. */
  30770. unbindInstanceAttributes(): void;
  30771. /**
  30772. * Release and free the memory of a vertex array object
  30773. * @param vao defines the vertex array object to delete
  30774. */
  30775. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30776. /** @hidden */
  30777. _releaseBuffer(buffer: DataBuffer): boolean;
  30778. /**
  30779. * Creates a webGL buffer to use with instanciation
  30780. * @param capacity defines the size of the buffer
  30781. * @returns the webGL buffer
  30782. */
  30783. createInstancesBuffer(capacity: number): DataBuffer;
  30784. /**
  30785. * Delete a webGL buffer used with instanciation
  30786. * @param buffer defines the webGL buffer to delete
  30787. */
  30788. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30789. /**
  30790. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30791. * @param instancesBuffer defines the webGL buffer to update and bind
  30792. * @param data defines the data to store in the buffer
  30793. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30794. */
  30795. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30796. /**
  30797. * Apply all cached states (depth, culling, stencil and alpha)
  30798. */
  30799. applyStates(): void;
  30800. /**
  30801. * Send a draw order
  30802. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30803. * @param indexStart defines the starting index
  30804. * @param indexCount defines the number of index to draw
  30805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30806. */
  30807. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30808. /**
  30809. * Draw a list of points
  30810. * @param verticesStart defines the index of first vertex to draw
  30811. * @param verticesCount defines the count of vertices to draw
  30812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30813. */
  30814. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30815. /**
  30816. * Draw a list of unindexed primitives
  30817. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30818. * @param verticesStart defines the index of first vertex to draw
  30819. * @param verticesCount defines the count of vertices to draw
  30820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30821. */
  30822. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30823. /**
  30824. * Draw a list of indexed primitives
  30825. * @param fillMode defines the primitive to use
  30826. * @param indexStart defines the starting index
  30827. * @param indexCount defines the number of index to draw
  30828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30829. */
  30830. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30831. /**
  30832. * Draw a list of unindexed primitives
  30833. * @param fillMode defines the primitive to use
  30834. * @param verticesStart defines the index of first vertex to draw
  30835. * @param verticesCount defines the count of vertices to draw
  30836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30837. */
  30838. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30839. private _drawMode;
  30840. /** @hidden */
  30841. _releaseEffect(effect: Effect): void;
  30842. /** @hidden */
  30843. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30844. /**
  30845. * Create a new effect (used to store vertex/fragment shaders)
  30846. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30847. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30848. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30849. * @param samplers defines an array of string used to represent textures
  30850. * @param defines defines the string containing the defines to use to compile the shaders
  30851. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30852. * @param onCompiled defines a function to call when the effect creation is successful
  30853. * @param onError defines a function to call when the effect creation has failed
  30854. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30855. * @returns the new Effect
  30856. */
  30857. 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;
  30858. private _compileShader;
  30859. private _compileRawShader;
  30860. /**
  30861. * Directly creates a webGL program
  30862. * @param pipelineContext defines the pipeline context to attach to
  30863. * @param vertexCode defines the vertex shader code to use
  30864. * @param fragmentCode defines the fragment shader code to use
  30865. * @param context defines the webGL context to use (if not set, the current one will be used)
  30866. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30867. * @returns the new webGL program
  30868. */
  30869. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30870. /**
  30871. * Creates a webGL program
  30872. * @param pipelineContext defines the pipeline context to attach to
  30873. * @param vertexCode defines the vertex shader code to use
  30874. * @param fragmentCode defines the fragment shader code to use
  30875. * @param defines defines the string containing the defines to use to compile the shaders
  30876. * @param context defines the webGL context to use (if not set, the current one will be used)
  30877. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30878. * @returns the new webGL program
  30879. */
  30880. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30881. /**
  30882. * Creates a new pipeline context
  30883. * @returns the new pipeline
  30884. */
  30885. createPipelineContext(): WebGLPipelineContext;
  30886. private _createShaderProgram;
  30887. private _finalizePipelineContext;
  30888. /** @hidden */
  30889. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30890. /** @hidden */
  30891. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30892. /** @hidden */
  30893. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30894. /**
  30895. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30896. * @param pipelineContext defines the pipeline context to use
  30897. * @param uniformsNames defines the list of uniform names
  30898. * @returns an array of webGL uniform locations
  30899. */
  30900. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30901. /**
  30902. * Gets the lsit of active attributes for a given webGL program
  30903. * @param pipelineContext defines the pipeline context to use
  30904. * @param attributesNames defines the list of attribute names to get
  30905. * @returns an array of indices indicating the offset of each attribute
  30906. */
  30907. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30908. /**
  30909. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30910. * @param effect defines the effect to activate
  30911. */
  30912. enableEffect(effect: Nullable<Effect>): void;
  30913. /**
  30914. * Set the value of an uniform to an array of int32
  30915. * @param uniform defines the webGL uniform location where to store the value
  30916. * @param array defines the array of int32 to store
  30917. */
  30918. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30919. /**
  30920. * Set the value of an uniform to an array of int32 (stored as vec2)
  30921. * @param uniform defines the webGL uniform location where to store the value
  30922. * @param array defines the array of int32 to store
  30923. */
  30924. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30925. /**
  30926. * Set the value of an uniform to an array of int32 (stored as vec3)
  30927. * @param uniform defines the webGL uniform location where to store the value
  30928. * @param array defines the array of int32 to store
  30929. */
  30930. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30931. /**
  30932. * Set the value of an uniform to an array of int32 (stored as vec4)
  30933. * @param uniform defines the webGL uniform location where to store the value
  30934. * @param array defines the array of int32 to store
  30935. */
  30936. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30937. /**
  30938. * Set the value of an uniform to an array of float32
  30939. * @param uniform defines the webGL uniform location where to store the value
  30940. * @param array defines the array of float32 to store
  30941. */
  30942. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30943. /**
  30944. * Set the value of an uniform to an array of float32 (stored as vec2)
  30945. * @param uniform defines the webGL uniform location where to store the value
  30946. * @param array defines the array of float32 to store
  30947. */
  30948. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30949. /**
  30950. * Set the value of an uniform to an array of float32 (stored as vec3)
  30951. * @param uniform defines the webGL uniform location where to store the value
  30952. * @param array defines the array of float32 to store
  30953. */
  30954. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30955. /**
  30956. * Set the value of an uniform to an array of float32 (stored as vec4)
  30957. * @param uniform defines the webGL uniform location where to store the value
  30958. * @param array defines the array of float32 to store
  30959. */
  30960. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30961. /**
  30962. * Set the value of an uniform to an array of number
  30963. * @param uniform defines the webGL uniform location where to store the value
  30964. * @param array defines the array of number to store
  30965. */
  30966. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30967. /**
  30968. * Set the value of an uniform to an array of number (stored as vec2)
  30969. * @param uniform defines the webGL uniform location where to store the value
  30970. * @param array defines the array of number to store
  30971. */
  30972. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30973. /**
  30974. * Set the value of an uniform to an array of number (stored as vec3)
  30975. * @param uniform defines the webGL uniform location where to store the value
  30976. * @param array defines the array of number to store
  30977. */
  30978. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30979. /**
  30980. * Set the value of an uniform to an array of number (stored as vec4)
  30981. * @param uniform defines the webGL uniform location where to store the value
  30982. * @param array defines the array of number to store
  30983. */
  30984. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30985. /**
  30986. * Set the value of an uniform to an array of float32 (stored as matrices)
  30987. * @param uniform defines the webGL uniform location where to store the value
  30988. * @param matrices defines the array of float32 to store
  30989. */
  30990. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30991. /**
  30992. * Set the value of an uniform to a matrix (3x3)
  30993. * @param uniform defines the webGL uniform location where to store the value
  30994. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30995. */
  30996. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30997. /**
  30998. * Set the value of an uniform to a matrix (2x2)
  30999. * @param uniform defines the webGL uniform location where to store the value
  31000. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31001. */
  31002. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31003. /**
  31004. * Set the value of an uniform to a number (int)
  31005. * @param uniform defines the webGL uniform location where to store the value
  31006. * @param value defines the int number to store
  31007. */
  31008. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31009. /**
  31010. * Set the value of an uniform to a number (float)
  31011. * @param uniform defines the webGL uniform location where to store the value
  31012. * @param value defines the float number to store
  31013. */
  31014. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31015. /**
  31016. * Set the value of an uniform to a vec2
  31017. * @param uniform defines the webGL uniform location where to store the value
  31018. * @param x defines the 1st component of the value
  31019. * @param y defines the 2nd component of the value
  31020. */
  31021. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31022. /**
  31023. * Set the value of an uniform to a vec3
  31024. * @param uniform defines the webGL uniform location where to store the value
  31025. * @param x defines the 1st component of the value
  31026. * @param y defines the 2nd component of the value
  31027. * @param z defines the 3rd component of the value
  31028. */
  31029. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31030. /**
  31031. * Set the value of an uniform to a boolean
  31032. * @param uniform defines the webGL uniform location where to store the value
  31033. * @param bool defines the boolean to store
  31034. */
  31035. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31036. /**
  31037. * Set the value of an uniform to a vec4
  31038. * @param uniform defines the webGL uniform location where to store the value
  31039. * @param x defines the 1st component of the value
  31040. * @param y defines the 2nd component of the value
  31041. * @param z defines the 3rd component of the value
  31042. * @param w defines the 4th component of the value
  31043. */
  31044. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31045. /**
  31046. * Sets a Color4 on a uniform variable
  31047. * @param uniform defines the uniform location
  31048. * @param color4 defines the value to be set
  31049. */
  31050. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31051. /**
  31052. * Set various states to the webGL context
  31053. * @param culling defines backface culling state
  31054. * @param zOffset defines the value to apply to zOffset (0 by default)
  31055. * @param force defines if states must be applied even if cache is up to date
  31056. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31057. */
  31058. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31059. /**
  31060. * Set the z offset to apply to current rendering
  31061. * @param value defines the offset to apply
  31062. */
  31063. setZOffset(value: number): void;
  31064. /**
  31065. * Gets the current value of the zOffset
  31066. * @returns the current zOffset state
  31067. */
  31068. getZOffset(): number;
  31069. /**
  31070. * Enable or disable depth buffering
  31071. * @param enable defines the state to set
  31072. */
  31073. setDepthBuffer(enable: boolean): void;
  31074. /**
  31075. * Gets a boolean indicating if depth writing is enabled
  31076. * @returns the current depth writing state
  31077. */
  31078. getDepthWrite(): boolean;
  31079. /**
  31080. * Enable or disable depth writing
  31081. * @param enable defines the state to set
  31082. */
  31083. setDepthWrite(enable: boolean): void;
  31084. /**
  31085. * Enable or disable color writing
  31086. * @param enable defines the state to set
  31087. */
  31088. setColorWrite(enable: boolean): void;
  31089. /**
  31090. * Gets a boolean indicating if color writing is enabled
  31091. * @returns the current color writing state
  31092. */
  31093. getColorWrite(): boolean;
  31094. /**
  31095. * Sets alpha constants used by some alpha blending modes
  31096. * @param r defines the red component
  31097. * @param g defines the green component
  31098. * @param b defines the blue component
  31099. * @param a defines the alpha component
  31100. */
  31101. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31102. /**
  31103. * Sets the current alpha mode
  31104. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31105. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31106. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31107. */
  31108. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31109. /**
  31110. * Gets the current alpha mode
  31111. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31112. * @returns the current alpha mode
  31113. */
  31114. getAlphaMode(): number;
  31115. /**
  31116. * Clears the list of texture accessible through engine.
  31117. * This can help preventing texture load conflict due to name collision.
  31118. */
  31119. clearInternalTexturesCache(): void;
  31120. /**
  31121. * Force the entire cache to be cleared
  31122. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31123. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31124. */
  31125. wipeCaches(bruteForce?: boolean): void;
  31126. /**
  31127. * Set the compressed texture format to use, based on the formats you have, and the formats
  31128. * supported by the hardware / browser.
  31129. *
  31130. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31131. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31132. * to API arguments needed to compressed textures. This puts the burden on the container
  31133. * generator to house the arcane code for determining these for current & future formats.
  31134. *
  31135. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31136. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31137. *
  31138. * Note: The result of this call is not taken into account when a texture is base64.
  31139. *
  31140. * @param formatsAvailable defines the list of those format families you have created
  31141. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31142. *
  31143. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31144. * @returns The extension selected.
  31145. */
  31146. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31147. /** @hidden */
  31148. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31149. min: number;
  31150. mag: number;
  31151. };
  31152. /** @hidden */
  31153. _createTexture(): WebGLTexture;
  31154. /**
  31155. * Usually called from Texture.ts.
  31156. * Passed information to create a WebGLTexture
  31157. * @param urlArg defines a value which contains one of the following:
  31158. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31159. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31160. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31161. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31162. * @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)
  31163. * @param scene needed for loading to the correct scene
  31164. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31165. * @param onLoad optional callback to be called upon successful completion
  31166. * @param onError optional callback to be called upon failure
  31167. * @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
  31168. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31169. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31170. * @param forcedExtension defines the extension to use to pick the right loader
  31171. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31172. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31173. */
  31174. 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;
  31175. /**
  31176. * @hidden
  31177. * Rescales a texture
  31178. * @param source input texutre
  31179. * @param destination destination texture
  31180. * @param scene scene to use to render the resize
  31181. * @param internalFormat format to use when resizing
  31182. * @param onComplete callback to be called when resize has completed
  31183. */
  31184. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31185. private _unpackFlipYCached;
  31186. /**
  31187. * In case you are sharing the context with other applications, it might
  31188. * be interested to not cache the unpack flip y state to ensure a consistent
  31189. * value would be set.
  31190. */
  31191. enableUnpackFlipYCached: boolean;
  31192. /** @hidden */
  31193. _unpackFlipY(value: boolean): void;
  31194. /** @hidden */
  31195. _getUnpackAlignement(): number;
  31196. /**
  31197. * Creates a dynamic texture
  31198. * @param width defines the width of the texture
  31199. * @param height defines the height of the texture
  31200. * @param generateMipMaps defines if the engine should generate the mip levels
  31201. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31202. * @returns the dynamic texture inside an InternalTexture
  31203. */
  31204. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31205. /**
  31206. * Update the sampling mode of a given texture
  31207. * @param samplingMode defines the required sampling mode
  31208. * @param texture defines the texture to update
  31209. */
  31210. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31211. /**
  31212. * Update the content of a dynamic texture
  31213. * @param texture defines the texture to update
  31214. * @param canvas defines the canvas containing the source
  31215. * @param invertY defines if data must be stored with Y axis inverted
  31216. * @param premulAlpha defines if alpha is stored as premultiplied
  31217. * @param format defines the format of the data
  31218. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31219. */
  31220. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31221. /**
  31222. * Update a video texture
  31223. * @param texture defines the texture to update
  31224. * @param video defines the video element to use
  31225. * @param invertY defines if data must be stored with Y axis inverted
  31226. */
  31227. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31228. /**
  31229. * Updates a depth texture Comparison Mode and Function.
  31230. * If the comparison Function is equal to 0, the mode will be set to none.
  31231. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31232. * @param texture The texture to set the comparison function for
  31233. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31234. */
  31235. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31236. /** @hidden */
  31237. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31238. width: number;
  31239. height: number;
  31240. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31241. /**
  31242. * Creates a depth stencil texture.
  31243. * This is only available in WebGL 2 or with the depth texture extension available.
  31244. * @param size The size of face edge in the texture.
  31245. * @param options The options defining the texture.
  31246. * @returns The texture
  31247. */
  31248. createDepthStencilTexture(size: number | {
  31249. width: number;
  31250. height: number;
  31251. }, options: DepthTextureCreationOptions): InternalTexture;
  31252. /**
  31253. * Creates a depth stencil texture.
  31254. * This is only available in WebGL 2 or with the depth texture extension available.
  31255. * @param size The size of face edge in the texture.
  31256. * @param options The options defining the texture.
  31257. * @returns The texture
  31258. */
  31259. private _createDepthStencilTexture;
  31260. /**
  31261. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31262. * @param renderTarget The render target to set the frame buffer for
  31263. */
  31264. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31265. /**
  31266. * Creates a new render target texture
  31267. * @param size defines the size of the texture
  31268. * @param options defines the options used to create the texture
  31269. * @returns a new render target texture stored in an InternalTexture
  31270. */
  31271. createRenderTargetTexture(size: number | {
  31272. width: number;
  31273. height: number;
  31274. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31275. /** @hidden */
  31276. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31277. /**
  31278. * Updates the sample count of a render target texture
  31279. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31280. * @param texture defines the texture to update
  31281. * @param samples defines the sample count to set
  31282. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31283. */
  31284. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31285. /** @hidden */
  31286. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31287. /** @hidden */
  31288. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31289. /** @hidden */
  31290. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31291. /** @hidden */
  31292. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31293. /**
  31294. * @hidden
  31295. */
  31296. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31297. private _prepareWebGLTextureContinuation;
  31298. private _prepareWebGLTexture;
  31299. /** @hidden */
  31300. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31301. /** @hidden */
  31302. _releaseFramebufferObjects(texture: InternalTexture): void;
  31303. /** @hidden */
  31304. _releaseTexture(texture: InternalTexture): void;
  31305. private setProgram;
  31306. private _boundUniforms;
  31307. /**
  31308. * Binds an effect to the webGL context
  31309. * @param effect defines the effect to bind
  31310. */
  31311. bindSamplers(effect: Effect): void;
  31312. private _activateCurrentTexture;
  31313. /** @hidden */
  31314. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31315. /** @hidden */
  31316. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31317. /**
  31318. * Sets a texture to the webGL context from a postprocess
  31319. * @param channel defines the channel to use
  31320. * @param postProcess defines the source postprocess
  31321. */
  31322. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31323. /**
  31324. * Binds the output of the passed in post process to the texture channel specified
  31325. * @param channel The channel the texture should be bound to
  31326. * @param postProcess The post process which's output should be bound
  31327. */
  31328. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31329. /**
  31330. * Unbind all textures from the webGL context
  31331. */
  31332. unbindAllTextures(): void;
  31333. /**
  31334. * Sets a texture to the according uniform.
  31335. * @param channel The texture channel
  31336. * @param uniform The uniform to set
  31337. * @param texture The texture to apply
  31338. */
  31339. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31340. /**
  31341. * Sets a depth stencil texture from a render target to the according uniform.
  31342. * @param channel The texture channel
  31343. * @param uniform The uniform to set
  31344. * @param texture The render target texture containing the depth stencil texture to apply
  31345. */
  31346. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31347. private _bindSamplerUniformToChannel;
  31348. private _getTextureWrapMode;
  31349. private _setTexture;
  31350. /**
  31351. * Sets an array of texture to the webGL context
  31352. * @param channel defines the channel where the texture array must be set
  31353. * @param uniform defines the associated uniform location
  31354. * @param textures defines the array of textures to bind
  31355. */
  31356. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31357. /** @hidden */
  31358. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31359. private _setTextureParameterFloat;
  31360. private _setTextureParameterInteger;
  31361. /**
  31362. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31363. * @param x defines the x coordinate of the rectangle where pixels must be read
  31364. * @param y defines the y coordinate of the rectangle where pixels must be read
  31365. * @param width defines the width of the rectangle where pixels must be read
  31366. * @param height defines the height of the rectangle where pixels must be read
  31367. * @returns a Uint8Array containing RGBA colors
  31368. */
  31369. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31370. /**
  31371. * Add an externaly attached data from its key.
  31372. * This method call will fail and return false, if such key already exists.
  31373. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31374. * @param key the unique key that identifies the data
  31375. * @param data the data object to associate to the key for this Engine instance
  31376. * @return true if no such key were already present and the data was added successfully, false otherwise
  31377. */
  31378. addExternalData<T>(key: string, data: T): boolean;
  31379. /**
  31380. * Get an externaly attached data from its key
  31381. * @param key the unique key that identifies the data
  31382. * @return the associated data, if present (can be null), or undefined if not present
  31383. */
  31384. getExternalData<T>(key: string): T;
  31385. /**
  31386. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31387. * @param key the unique key that identifies the data
  31388. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31389. * @return the associated data, can be null if the factory returned null.
  31390. */
  31391. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31392. /**
  31393. * Remove an externaly attached data from the Engine instance
  31394. * @param key the unique key that identifies the data
  31395. * @return true if the data was successfully removed, false if it doesn't exist
  31396. */
  31397. removeExternalData(key: string): boolean;
  31398. /**
  31399. * Unbind all vertex attributes from the webGL context
  31400. */
  31401. unbindAllAttributes(): void;
  31402. /**
  31403. * 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
  31404. */
  31405. releaseEffects(): void;
  31406. /**
  31407. * Dispose and release all associated resources
  31408. */
  31409. dispose(): void;
  31410. /**
  31411. * Display the loading screen
  31412. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31413. */
  31414. displayLoadingUI(): void;
  31415. /**
  31416. * Hide the loading screen
  31417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31418. */
  31419. hideLoadingUI(): void;
  31420. /**
  31421. * Gets the current loading screen object
  31422. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31423. */
  31424. /**
  31425. * Sets the current loading screen object
  31426. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31427. */
  31428. loadingScreen: ILoadingScreen;
  31429. /**
  31430. * Sets the current loading screen text
  31431. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31432. */
  31433. loadingUIText: string;
  31434. /**
  31435. * Sets the current loading screen background color
  31436. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31437. */
  31438. loadingUIBackgroundColor: string;
  31439. /**
  31440. * Attach a new callback raised when context lost event is fired
  31441. * @param callback defines the callback to call
  31442. */
  31443. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31444. /**
  31445. * Attach a new callback raised when context restored event is fired
  31446. * @param callback defines the callback to call
  31447. */
  31448. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31449. /**
  31450. * Gets the source code of the vertex shader associated with a specific webGL program
  31451. * @param program defines the program to use
  31452. * @returns a string containing the source code of the vertex shader associated with the program
  31453. */
  31454. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31455. /**
  31456. * Gets the source code of the fragment shader associated with a specific webGL program
  31457. * @param program defines the program to use
  31458. * @returns a string containing the source code of the fragment shader associated with the program
  31459. */
  31460. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31461. /**
  31462. * Get the current error code of the webGL context
  31463. * @returns the error code
  31464. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31465. */
  31466. getError(): number;
  31467. /**
  31468. * Gets the current framerate
  31469. * @returns a number representing the framerate
  31470. */
  31471. getFps(): number;
  31472. /**
  31473. * Gets the time spent between current and previous frame
  31474. * @returns a number representing the delta time in ms
  31475. */
  31476. getDeltaTime(): number;
  31477. private _measureFps;
  31478. /** @hidden */
  31479. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31480. private _canRenderToFloatFramebuffer;
  31481. private _canRenderToHalfFloatFramebuffer;
  31482. private _canRenderToFramebuffer;
  31483. /** @hidden */
  31484. _getWebGLTextureType(type: number): number;
  31485. /** @hidden */
  31486. _getInternalFormat(format: number): number;
  31487. /** @hidden */
  31488. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31489. /** @hidden */
  31490. _getRGBAMultiSampleBufferFormat(type: number): number;
  31491. /** @hidden */
  31492. _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;
  31493. /** @hidden */
  31494. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31495. /**
  31496. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31497. * @returns true if the engine can be created
  31498. * @ignorenaming
  31499. */
  31500. static isSupported(): boolean;
  31501. /**
  31502. * Find the next highest power of two.
  31503. * @param x Number to start search from.
  31504. * @return Next highest power of two.
  31505. */
  31506. static CeilingPOT(x: number): number;
  31507. /**
  31508. * Find the next lowest power of two.
  31509. * @param x Number to start search from.
  31510. * @return Next lowest power of two.
  31511. */
  31512. static FloorPOT(x: number): number;
  31513. /**
  31514. * Find the nearest power of two.
  31515. * @param x Number to start search from.
  31516. * @return Next nearest power of two.
  31517. */
  31518. static NearestPOT(x: number): number;
  31519. /**
  31520. * Get the closest exponent of two
  31521. * @param value defines the value to approximate
  31522. * @param max defines the maximum value to return
  31523. * @param mode defines how to define the closest value
  31524. * @returns closest exponent of two of the given value
  31525. */
  31526. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31527. /**
  31528. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31529. * @param func - the function to be called
  31530. * @param requester - the object that will request the next frame. Falls back to window.
  31531. * @returns frame number
  31532. */
  31533. static QueueNewFrame(func: () => void, requester?: any): number;
  31534. /**
  31535. * Ask the browser to promote the current element to pointerlock mode
  31536. * @param element defines the DOM element to promote
  31537. */
  31538. static _RequestPointerlock(element: HTMLElement): void;
  31539. /**
  31540. * Asks the browser to exit pointerlock mode
  31541. */
  31542. static _ExitPointerlock(): void;
  31543. /**
  31544. * Ask the browser to promote the current element to fullscreen rendering mode
  31545. * @param element defines the DOM element to promote
  31546. */
  31547. static _RequestFullscreen(element: HTMLElement): void;
  31548. /**
  31549. * Asks the browser to exit fullscreen mode
  31550. */
  31551. static _ExitFullscreen(): void;
  31552. }
  31553. }
  31554. declare module BABYLON {
  31555. /**
  31556. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31557. * during the life time of the application.
  31558. */
  31559. export class EngineStore {
  31560. /** Gets the list of created engines */
  31561. static Instances: Engine[];
  31562. /** @hidden */
  31563. static _LastCreatedScene: Nullable<Scene>;
  31564. /**
  31565. * Gets the latest created engine
  31566. */
  31567. static readonly LastCreatedEngine: Nullable<Engine>;
  31568. /**
  31569. * Gets the latest created scene
  31570. */
  31571. static readonly LastCreatedScene: Nullable<Scene>;
  31572. /**
  31573. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31574. * @ignorenaming
  31575. */
  31576. static UseFallbackTexture: boolean;
  31577. /**
  31578. * Texture content used if a texture cannot loaded
  31579. * @ignorenaming
  31580. */
  31581. static FallbackTexture: string;
  31582. }
  31583. }
  31584. declare module BABYLON {
  31585. /**
  31586. * Helper class that provides a small promise polyfill
  31587. */
  31588. export class PromisePolyfill {
  31589. /**
  31590. * Static function used to check if the polyfill is required
  31591. * If this is the case then the function will inject the polyfill to window.Promise
  31592. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31593. */
  31594. static Apply(force?: boolean): void;
  31595. }
  31596. }
  31597. declare module BABYLON {
  31598. /**
  31599. * Interface for screenshot methods with describe argument called `size` as object with options
  31600. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31601. */
  31602. export interface IScreenshotSize {
  31603. /**
  31604. * number in pixels for canvas height
  31605. */
  31606. height?: number;
  31607. /**
  31608. * multiplier allowing render at a higher or lower resolution
  31609. * If value is defined then height and width will be ignored and taken from camera
  31610. */
  31611. precision?: number;
  31612. /**
  31613. * number in pixels for canvas width
  31614. */
  31615. width?: number;
  31616. }
  31617. }
  31618. declare module BABYLON {
  31619. interface IColor4Like {
  31620. r: float;
  31621. g: float;
  31622. b: float;
  31623. a: float;
  31624. }
  31625. /**
  31626. * Class containing a set of static utilities functions
  31627. */
  31628. export class Tools {
  31629. /**
  31630. * Gets or sets the base URL to use to load assets
  31631. */
  31632. static BaseUrl: string;
  31633. /**
  31634. * Enable/Disable Custom HTTP Request Headers globally.
  31635. * default = false
  31636. * @see CustomRequestHeaders
  31637. */
  31638. static UseCustomRequestHeaders: boolean;
  31639. /**
  31640. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31641. * i.e. when loading files, where the server/service expects an Authorization header
  31642. */
  31643. static CustomRequestHeaders: {
  31644. [key: string]: string;
  31645. };
  31646. /**
  31647. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31648. */
  31649. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31650. /**
  31651. * Default behaviour for cors in the application.
  31652. * It can be a string if the expected behavior is identical in the entire app.
  31653. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31654. */
  31655. static CorsBehavior: string | ((url: string | string[]) => string);
  31656. /**
  31657. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31658. * @ignorenaming
  31659. */
  31660. static UseFallbackTexture: boolean;
  31661. /**
  31662. * Use this object to register external classes like custom textures or material
  31663. * to allow the laoders to instantiate them
  31664. */
  31665. static RegisteredExternalClasses: {
  31666. [key: string]: Object;
  31667. };
  31668. /**
  31669. * Texture content used if a texture cannot loaded
  31670. * @ignorenaming
  31671. */
  31672. static fallbackTexture: string;
  31673. /**
  31674. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31675. * @param u defines the coordinate on X axis
  31676. * @param v defines the coordinate on Y axis
  31677. * @param width defines the width of the source data
  31678. * @param height defines the height of the source data
  31679. * @param pixels defines the source byte array
  31680. * @param color defines the output color
  31681. */
  31682. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31683. /**
  31684. * Interpolates between a and b via alpha
  31685. * @param a The lower value (returned when alpha = 0)
  31686. * @param b The upper value (returned when alpha = 1)
  31687. * @param alpha The interpolation-factor
  31688. * @return The mixed value
  31689. */
  31690. static Mix(a: number, b: number, alpha: number): number;
  31691. /**
  31692. * Tries to instantiate a new object from a given class name
  31693. * @param className defines the class name to instantiate
  31694. * @returns the new object or null if the system was not able to do the instantiation
  31695. */
  31696. static Instantiate(className: string): any;
  31697. /**
  31698. * Provides a slice function that will work even on IE
  31699. * @param data defines the array to slice
  31700. * @param start defines the start of the data (optional)
  31701. * @param end defines the end of the data (optional)
  31702. * @returns the new sliced array
  31703. */
  31704. static Slice<T>(data: T, start?: number, end?: number): T;
  31705. /**
  31706. * Polyfill for setImmediate
  31707. * @param action defines the action to execute after the current execution block
  31708. */
  31709. static SetImmediate(action: () => void): void;
  31710. /**
  31711. * Function indicating if a number is an exponent of 2
  31712. * @param value defines the value to test
  31713. * @returns true if the value is an exponent of 2
  31714. */
  31715. static IsExponentOfTwo(value: number): boolean;
  31716. private static _tmpFloatArray;
  31717. /**
  31718. * Returns the nearest 32-bit single precision float representation of a Number
  31719. * @param value A Number. If the parameter is of a different type, it will get converted
  31720. * to a number or to NaN if it cannot be converted
  31721. * @returns number
  31722. */
  31723. static FloatRound(value: number): number;
  31724. /**
  31725. * Extracts the filename from a path
  31726. * @param path defines the path to use
  31727. * @returns the filename
  31728. */
  31729. static GetFilename(path: string): string;
  31730. /**
  31731. * Extracts the "folder" part of a path (everything before the filename).
  31732. * @param uri The URI to extract the info from
  31733. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31734. * @returns The "folder" part of the path
  31735. */
  31736. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31737. /**
  31738. * Extracts text content from a DOM element hierarchy
  31739. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31740. */
  31741. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31742. /**
  31743. * Convert an angle in radians to degrees
  31744. * @param angle defines the angle to convert
  31745. * @returns the angle in degrees
  31746. */
  31747. static ToDegrees(angle: number): number;
  31748. /**
  31749. * Convert an angle in degrees to radians
  31750. * @param angle defines the angle to convert
  31751. * @returns the angle in radians
  31752. */
  31753. static ToRadians(angle: number): number;
  31754. /**
  31755. * Encode a buffer to a base64 string
  31756. * @param buffer defines the buffer to encode
  31757. * @returns the encoded string
  31758. */
  31759. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31760. /**
  31761. * Returns an array if obj is not an array
  31762. * @param obj defines the object to evaluate as an array
  31763. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31764. * @returns either obj directly if obj is an array or a new array containing obj
  31765. */
  31766. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31767. /**
  31768. * Gets the pointer prefix to use
  31769. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31770. */
  31771. static GetPointerPrefix(): string;
  31772. /**
  31773. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31774. * @param url define the url we are trying
  31775. * @param element define the dom element where to configure the cors policy
  31776. */
  31777. static SetCorsBehavior(url: string | string[], element: {
  31778. crossOrigin: string | null;
  31779. }): void;
  31780. /**
  31781. * Removes unwanted characters from an url
  31782. * @param url defines the url to clean
  31783. * @returns the cleaned url
  31784. */
  31785. static CleanUrl(url: string): string;
  31786. /**
  31787. * Gets or sets a function used to pre-process url before using them to load assets
  31788. */
  31789. static PreprocessUrl: (url: string) => string;
  31790. /**
  31791. * Loads an image as an HTMLImageElement.
  31792. * @param input url string, ArrayBuffer, or Blob to load
  31793. * @param onLoad callback called when the image successfully loads
  31794. * @param onError callback called when the image fails to load
  31795. * @param offlineProvider offline provider for caching
  31796. * @returns the HTMLImageElement of the loaded image
  31797. */
  31798. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31799. /**
  31800. * Loads a file
  31801. * @param url url string, ArrayBuffer, or Blob to load
  31802. * @param onSuccess callback called when the file successfully loads
  31803. * @param onProgress callback called while file is loading (if the server supports this mode)
  31804. * @param offlineProvider defines the offline provider for caching
  31805. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31806. * @param onError callback called when the file fails to load
  31807. * @returns a file request object
  31808. */
  31809. 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;
  31810. /**
  31811. * Loads a file from a url
  31812. * @param url the file url to load
  31813. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31814. */
  31815. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31816. /**
  31817. * Load a script (identified by an url). When the url returns, the
  31818. * content of this file is added into a new script element, attached to the DOM (body element)
  31819. * @param scriptUrl defines the url of the script to laod
  31820. * @param onSuccess defines the callback called when the script is loaded
  31821. * @param onError defines the callback to call if an error occurs
  31822. * @param scriptId defines the id of the script element
  31823. */
  31824. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31825. /**
  31826. * Load an asynchronous script (identified by an url). When the url returns, the
  31827. * content of this file is added into a new script element, attached to the DOM (body element)
  31828. * @param scriptUrl defines the url of the script to laod
  31829. * @param scriptId defines the id of the script element
  31830. * @returns a promise request object
  31831. */
  31832. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31833. /**
  31834. * Loads a file from a blob
  31835. * @param fileToLoad defines the blob to use
  31836. * @param callback defines the callback to call when data is loaded
  31837. * @param progressCallback defines the callback to call during loading process
  31838. * @returns a file request object
  31839. */
  31840. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31841. /**
  31842. * Loads a file
  31843. * @param fileToLoad defines the file to load
  31844. * @param callback defines the callback to call when data is loaded
  31845. * @param progressCallBack defines the callback to call during loading process
  31846. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31847. * @returns a file request object
  31848. */
  31849. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31850. /**
  31851. * Creates a data url from a given string content
  31852. * @param content defines the content to convert
  31853. * @returns the new data url link
  31854. */
  31855. static FileAsURL(content: string): string;
  31856. /**
  31857. * Format the given number to a specific decimal format
  31858. * @param value defines the number to format
  31859. * @param decimals defines the number of decimals to use
  31860. * @returns the formatted string
  31861. */
  31862. static Format(value: number, decimals?: number): string;
  31863. /**
  31864. * Tries to copy an object by duplicating every property
  31865. * @param source defines the source object
  31866. * @param destination defines the target object
  31867. * @param doNotCopyList defines a list of properties to avoid
  31868. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31869. */
  31870. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31871. /**
  31872. * Gets a boolean indicating if the given object has no own property
  31873. * @param obj defines the object to test
  31874. * @returns true if object has no own property
  31875. */
  31876. static IsEmpty(obj: any): boolean;
  31877. /**
  31878. * Function used to register events at window level
  31879. * @param windowElement defines the Window object to use
  31880. * @param events defines the events to register
  31881. */
  31882. static RegisterTopRootEvents(windowElement: Window, events: {
  31883. name: string;
  31884. handler: Nullable<(e: FocusEvent) => any>;
  31885. }[]): void;
  31886. /**
  31887. * Function used to unregister events from window level
  31888. * @param windowElement defines the Window object to use
  31889. * @param events defines the events to unregister
  31890. */
  31891. static UnregisterTopRootEvents(windowElement: Window, events: {
  31892. name: string;
  31893. handler: Nullable<(e: FocusEvent) => any>;
  31894. }[]): void;
  31895. /**
  31896. * @ignore
  31897. */
  31898. static _ScreenshotCanvas: HTMLCanvasElement;
  31899. /**
  31900. * Dumps the current bound framebuffer
  31901. * @param width defines the rendering width
  31902. * @param height defines the rendering height
  31903. * @param engine defines the hosting engine
  31904. * @param successCallback defines the callback triggered once the data are available
  31905. * @param mimeType defines the mime type of the result
  31906. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31907. */
  31908. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31909. /**
  31910. * Converts the canvas data to blob.
  31911. * This acts as a polyfill for browsers not supporting the to blob function.
  31912. * @param canvas Defines the canvas to extract the data from
  31913. * @param successCallback Defines the callback triggered once the data are available
  31914. * @param mimeType Defines the mime type of the result
  31915. */
  31916. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31917. /**
  31918. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31919. * @param successCallback defines the callback triggered once the data are available
  31920. * @param mimeType defines the mime type of the result
  31921. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31922. */
  31923. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31924. /**
  31925. * Downloads a blob in the browser
  31926. * @param blob defines the blob to download
  31927. * @param fileName defines the name of the downloaded file
  31928. */
  31929. static Download(blob: Blob, fileName: string): void;
  31930. /**
  31931. * Captures a screenshot of the current rendering
  31932. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31933. * @param engine defines the rendering engine
  31934. * @param camera defines the source camera
  31935. * @param size This parameter can be set to a single number or to an object with the
  31936. * following (optional) properties: precision, width, height. If a single number is passed,
  31937. * it will be used for both width and height. If an object is passed, the screenshot size
  31938. * will be derived from the parameters. The precision property is a multiplier allowing
  31939. * rendering at a higher or lower resolution
  31940. * @param successCallback defines the callback receives a single parameter which contains the
  31941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31942. * src parameter of an <img> to display it
  31943. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31944. * Check your browser for supported MIME types
  31945. */
  31946. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31947. /**
  31948. * Captures a screenshot of the current rendering
  31949. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31950. * @param engine defines the rendering engine
  31951. * @param camera defines the source camera
  31952. * @param size This parameter can be set to a single number or to an object with the
  31953. * following (optional) properties: precision, width, height. If a single number is passed,
  31954. * it will be used for both width and height. If an object is passed, the screenshot size
  31955. * will be derived from the parameters. The precision property is a multiplier allowing
  31956. * rendering at a higher or lower resolution
  31957. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31958. * Check your browser for supported MIME types
  31959. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31960. * to the src parameter of an <img> to display it
  31961. */
  31962. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31963. /**
  31964. * Generates an image screenshot from the specified camera.
  31965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31966. * @param engine The engine to use for rendering
  31967. * @param camera The camera to use for rendering
  31968. * @param size This parameter can be set to a single number or to an object with the
  31969. * following (optional) properties: precision, width, height. If a single number is passed,
  31970. * it will be used for both width and height. If an object is passed, the screenshot size
  31971. * will be derived from the parameters. The precision property is a multiplier allowing
  31972. * rendering at a higher or lower resolution
  31973. * @param successCallback The callback receives a single parameter which contains the
  31974. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31975. * src parameter of an <img> to display it
  31976. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31977. * Check your browser for supported MIME types
  31978. * @param samples Texture samples (default: 1)
  31979. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31980. * @param fileName A name for for the downloaded file.
  31981. */
  31982. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31983. /**
  31984. * Generates an image screenshot from the specified camera.
  31985. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31986. * @param engine The engine to use for rendering
  31987. * @param camera The camera to use for rendering
  31988. * @param size This parameter can be set to a single number or to an object with the
  31989. * following (optional) properties: precision, width, height. If a single number is passed,
  31990. * it will be used for both width and height. If an object is passed, the screenshot size
  31991. * will be derived from the parameters. The precision property is a multiplier allowing
  31992. * rendering at a higher or lower resolution
  31993. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31994. * Check your browser for supported MIME types
  31995. * @param samples Texture samples (default: 1)
  31996. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31997. * @param fileName A name for for the downloaded file.
  31998. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31999. * to the src parameter of an <img> to display it
  32000. */
  32001. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32002. /**
  32003. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32004. * Be aware Math.random() could cause collisions, but:
  32005. * "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"
  32006. * @returns a pseudo random id
  32007. */
  32008. static RandomId(): string;
  32009. /**
  32010. * Test if the given uri is a base64 string
  32011. * @param uri The uri to test
  32012. * @return True if the uri is a base64 string or false otherwise
  32013. */
  32014. static IsBase64(uri: string): boolean;
  32015. /**
  32016. * Decode the given base64 uri.
  32017. * @param uri The uri to decode
  32018. * @return The decoded base64 data.
  32019. */
  32020. static DecodeBase64(uri: string): ArrayBuffer;
  32021. /**
  32022. * Gets the absolute url.
  32023. * @param url the input url
  32024. * @return the absolute url
  32025. */
  32026. static GetAbsoluteUrl(url: string): string;
  32027. /**
  32028. * No log
  32029. */
  32030. static readonly NoneLogLevel: number;
  32031. /**
  32032. * Only message logs
  32033. */
  32034. static readonly MessageLogLevel: number;
  32035. /**
  32036. * Only warning logs
  32037. */
  32038. static readonly WarningLogLevel: number;
  32039. /**
  32040. * Only error logs
  32041. */
  32042. static readonly ErrorLogLevel: number;
  32043. /**
  32044. * All logs
  32045. */
  32046. static readonly AllLogLevel: number;
  32047. /**
  32048. * Gets a value indicating the number of loading errors
  32049. * @ignorenaming
  32050. */
  32051. static readonly errorsCount: number;
  32052. /**
  32053. * Callback called when a new log is added
  32054. */
  32055. static OnNewCacheEntry: (entry: string) => void;
  32056. /**
  32057. * Log a message to the console
  32058. * @param message defines the message to log
  32059. */
  32060. static Log(message: string): void;
  32061. /**
  32062. * Write a warning message to the console
  32063. * @param message defines the message to log
  32064. */
  32065. static Warn(message: string): void;
  32066. /**
  32067. * Write an error message to the console
  32068. * @param message defines the message to log
  32069. */
  32070. static Error(message: string): void;
  32071. /**
  32072. * Gets current log cache (list of logs)
  32073. */
  32074. static readonly LogCache: string;
  32075. /**
  32076. * Clears the log cache
  32077. */
  32078. static ClearLogCache(): void;
  32079. /**
  32080. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32081. */
  32082. static LogLevels: number;
  32083. /**
  32084. * Checks if the window object exists
  32085. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32086. */
  32087. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32088. /**
  32089. * No performance log
  32090. */
  32091. static readonly PerformanceNoneLogLevel: number;
  32092. /**
  32093. * Use user marks to log performance
  32094. */
  32095. static readonly PerformanceUserMarkLogLevel: number;
  32096. /**
  32097. * Log performance to the console
  32098. */
  32099. static readonly PerformanceConsoleLogLevel: number;
  32100. private static _performance;
  32101. /**
  32102. * Sets the current performance log level
  32103. */
  32104. static PerformanceLogLevel: number;
  32105. private static _StartPerformanceCounterDisabled;
  32106. private static _EndPerformanceCounterDisabled;
  32107. private static _StartUserMark;
  32108. private static _EndUserMark;
  32109. private static _StartPerformanceConsole;
  32110. private static _EndPerformanceConsole;
  32111. /**
  32112. * Starts a performance counter
  32113. */
  32114. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32115. /**
  32116. * Ends a specific performance coutner
  32117. */
  32118. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32119. /**
  32120. * Gets either window.performance.now() if supported or Date.now() else
  32121. */
  32122. static readonly Now: number;
  32123. /**
  32124. * This method will return the name of the class used to create the instance of the given object.
  32125. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32126. * @param object the object to get the class name from
  32127. * @param isType defines if the object is actually a type
  32128. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32129. */
  32130. static GetClassName(object: any, isType?: boolean): string;
  32131. /**
  32132. * Gets the first element of an array satisfying a given predicate
  32133. * @param array defines the array to browse
  32134. * @param predicate defines the predicate to use
  32135. * @returns null if not found or the element
  32136. */
  32137. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32138. /**
  32139. * This method will return the name of the full name of the class, including its owning module (if any).
  32140. * 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).
  32141. * @param object the object to get the class name from
  32142. * @param isType defines if the object is actually a type
  32143. * @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.
  32144. * @ignorenaming
  32145. */
  32146. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32147. /**
  32148. * Returns a promise that resolves after the given amount of time.
  32149. * @param delay Number of milliseconds to delay
  32150. * @returns Promise that resolves after the given amount of time
  32151. */
  32152. static DelayAsync(delay: number): Promise<void>;
  32153. }
  32154. /**
  32155. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32156. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32157. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32158. * @param name The name of the class, case should be preserved
  32159. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32160. */
  32161. export function className(name: string, module?: string): (target: Object) => void;
  32162. /**
  32163. * An implementation of a loop for asynchronous functions.
  32164. */
  32165. export class AsyncLoop {
  32166. /**
  32167. * Defines the number of iterations for the loop
  32168. */
  32169. iterations: number;
  32170. /**
  32171. * Defines the current index of the loop.
  32172. */
  32173. index: number;
  32174. private _done;
  32175. private _fn;
  32176. private _successCallback;
  32177. /**
  32178. * Constructor.
  32179. * @param iterations the number of iterations.
  32180. * @param func the function to run each iteration
  32181. * @param successCallback the callback that will be called upon succesful execution
  32182. * @param offset starting offset.
  32183. */
  32184. constructor(
  32185. /**
  32186. * Defines the number of iterations for the loop
  32187. */
  32188. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32189. /**
  32190. * Execute the next iteration. Must be called after the last iteration was finished.
  32191. */
  32192. executeNext(): void;
  32193. /**
  32194. * Break the loop and run the success callback.
  32195. */
  32196. breakLoop(): void;
  32197. /**
  32198. * Create and run an async loop.
  32199. * @param iterations the number of iterations.
  32200. * @param fn the function to run each iteration
  32201. * @param successCallback the callback that will be called upon succesful execution
  32202. * @param offset starting offset.
  32203. * @returns the created async loop object
  32204. */
  32205. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32206. /**
  32207. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32208. * @param iterations total number of iterations
  32209. * @param syncedIterations number of synchronous iterations in each async iteration.
  32210. * @param fn the function to call each iteration.
  32211. * @param callback a success call back that will be called when iterating stops.
  32212. * @param breakFunction a break condition (optional)
  32213. * @param timeout timeout settings for the setTimeout function. default - 0.
  32214. * @returns the created async loop object
  32215. */
  32216. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32217. }
  32218. }
  32219. declare module BABYLON {
  32220. /** @hidden */
  32221. export interface ICollisionCoordinator {
  32222. createCollider(): Collider;
  32223. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32224. init(scene: Scene): void;
  32225. }
  32226. /** @hidden */
  32227. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32228. private _scene;
  32229. private _scaledPosition;
  32230. private _scaledVelocity;
  32231. private _finalPosition;
  32232. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32233. createCollider(): Collider;
  32234. init(scene: Scene): void;
  32235. private _collideWithWorld;
  32236. }
  32237. }
  32238. declare module BABYLON {
  32239. /**
  32240. * Class used to manage all inputs for the scene.
  32241. */
  32242. export class InputManager {
  32243. /** The distance in pixel that you have to move to prevent some events */
  32244. static DragMovementThreshold: number;
  32245. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32246. static LongPressDelay: number;
  32247. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32248. static DoubleClickDelay: number;
  32249. /** If you need to check double click without raising a single click at first click, enable this flag */
  32250. static ExclusiveDoubleClickMode: boolean;
  32251. private _wheelEventName;
  32252. private _onPointerMove;
  32253. private _onPointerDown;
  32254. private _onPointerUp;
  32255. private _initClickEvent;
  32256. private _initActionManager;
  32257. private _delayedSimpleClick;
  32258. private _delayedSimpleClickTimeout;
  32259. private _previousDelayedSimpleClickTimeout;
  32260. private _meshPickProceed;
  32261. private _previousButtonPressed;
  32262. private _currentPickResult;
  32263. private _previousPickResult;
  32264. private _totalPointersPressed;
  32265. private _doubleClickOccured;
  32266. private _pointerOverMesh;
  32267. private _pickedDownMesh;
  32268. private _pickedUpMesh;
  32269. private _pointerX;
  32270. private _pointerY;
  32271. private _unTranslatedPointerX;
  32272. private _unTranslatedPointerY;
  32273. private _startingPointerPosition;
  32274. private _previousStartingPointerPosition;
  32275. private _startingPointerTime;
  32276. private _previousStartingPointerTime;
  32277. private _pointerCaptures;
  32278. private _onKeyDown;
  32279. private _onKeyUp;
  32280. private _onCanvasFocusObserver;
  32281. private _onCanvasBlurObserver;
  32282. private _scene;
  32283. /**
  32284. * Creates a new InputManager
  32285. * @param scene defines the hosting scene
  32286. */
  32287. constructor(scene: Scene);
  32288. /**
  32289. * Gets the mesh that is currently under the pointer
  32290. */
  32291. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32292. /**
  32293. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32294. */
  32295. readonly unTranslatedPointer: Vector2;
  32296. /**
  32297. * Gets or sets the current on-screen X position of the pointer
  32298. */
  32299. pointerX: number;
  32300. /**
  32301. * Gets or sets the current on-screen Y position of the pointer
  32302. */
  32303. pointerY: number;
  32304. private _updatePointerPosition;
  32305. private _processPointerMove;
  32306. private _setRayOnPointerInfo;
  32307. private _checkPrePointerObservable;
  32308. /**
  32309. * Use this method to simulate a pointer move on a mesh
  32310. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32311. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32312. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32313. */
  32314. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32315. /**
  32316. * Use this method to simulate a pointer down on a mesh
  32317. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32318. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32319. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32320. */
  32321. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32322. private _processPointerDown;
  32323. /** @hidden */
  32324. _isPointerSwiping(): boolean;
  32325. /**
  32326. * Use this method to simulate a pointer up on a mesh
  32327. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32328. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32329. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32330. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32331. */
  32332. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32333. private _processPointerUp;
  32334. /**
  32335. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32336. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32337. * @returns true if the pointer was captured
  32338. */
  32339. isPointerCaptured(pointerId?: number): boolean;
  32340. /**
  32341. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32342. * @param attachUp defines if you want to attach events to pointerup
  32343. * @param attachDown defines if you want to attach events to pointerdown
  32344. * @param attachMove defines if you want to attach events to pointermove
  32345. */
  32346. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32347. /**
  32348. * Detaches all event handlers
  32349. */
  32350. detachControl(): void;
  32351. /**
  32352. * Force the value of meshUnderPointer
  32353. * @param mesh defines the mesh to use
  32354. */
  32355. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32356. /**
  32357. * Gets the mesh under the pointer
  32358. * @returns a Mesh or null if no mesh is under the pointer
  32359. */
  32360. getPointerOverMesh(): Nullable<AbstractMesh>;
  32361. }
  32362. }
  32363. declare module BABYLON {
  32364. /**
  32365. * Helper class used to generate session unique ID
  32366. */
  32367. export class UniqueIdGenerator {
  32368. private static _UniqueIdCounter;
  32369. /**
  32370. * Gets an unique (relatively to the current scene) Id
  32371. */
  32372. static readonly UniqueId: number;
  32373. }
  32374. }
  32375. declare module BABYLON {
  32376. /**
  32377. * This class defines the direct association between an animation and a target
  32378. */
  32379. export class TargetedAnimation {
  32380. /**
  32381. * Animation to perform
  32382. */
  32383. animation: Animation;
  32384. /**
  32385. * Target to animate
  32386. */
  32387. target: any;
  32388. /**
  32389. * Serialize the object
  32390. * @returns the JSON object representing the current entity
  32391. */
  32392. serialize(): any;
  32393. }
  32394. /**
  32395. * Use this class to create coordinated animations on multiple targets
  32396. */
  32397. export class AnimationGroup implements IDisposable {
  32398. /** The name of the animation group */
  32399. name: string;
  32400. private _scene;
  32401. private _targetedAnimations;
  32402. private _animatables;
  32403. private _from;
  32404. private _to;
  32405. private _isStarted;
  32406. private _isPaused;
  32407. private _speedRatio;
  32408. private _loopAnimation;
  32409. /**
  32410. * Gets or sets the unique id of the node
  32411. */
  32412. uniqueId: number;
  32413. /**
  32414. * This observable will notify when one animation have ended
  32415. */
  32416. onAnimationEndObservable: Observable<TargetedAnimation>;
  32417. /**
  32418. * Observer raised when one animation loops
  32419. */
  32420. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32421. /**
  32422. * This observable will notify when all animations have ended.
  32423. */
  32424. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32425. /**
  32426. * This observable will notify when all animations have paused.
  32427. */
  32428. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32429. /**
  32430. * This observable will notify when all animations are playing.
  32431. */
  32432. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32433. /**
  32434. * Gets the first frame
  32435. */
  32436. readonly from: number;
  32437. /**
  32438. * Gets the last frame
  32439. */
  32440. readonly to: number;
  32441. /**
  32442. * Define if the animations are started
  32443. */
  32444. readonly isStarted: boolean;
  32445. /**
  32446. * Gets a value indicating that the current group is playing
  32447. */
  32448. readonly isPlaying: boolean;
  32449. /**
  32450. * Gets or sets the speed ratio to use for all animations
  32451. */
  32452. /**
  32453. * Gets or sets the speed ratio to use for all animations
  32454. */
  32455. speedRatio: number;
  32456. /**
  32457. * Gets or sets if all animations should loop or not
  32458. */
  32459. loopAnimation: boolean;
  32460. /**
  32461. * Gets the targeted animations for this animation group
  32462. */
  32463. readonly targetedAnimations: Array<TargetedAnimation>;
  32464. /**
  32465. * returning the list of animatables controlled by this animation group.
  32466. */
  32467. readonly animatables: Array<Animatable>;
  32468. /**
  32469. * Instantiates a new Animation Group.
  32470. * This helps managing several animations at once.
  32471. * @see http://doc.babylonjs.com/how_to/group
  32472. * @param name Defines the name of the group
  32473. * @param scene Defines the scene the group belongs to
  32474. */
  32475. constructor(
  32476. /** The name of the animation group */
  32477. name: string, scene?: Nullable<Scene>);
  32478. /**
  32479. * Add an animation (with its target) in the group
  32480. * @param animation defines the animation we want to add
  32481. * @param target defines the target of the animation
  32482. * @returns the TargetedAnimation object
  32483. */
  32484. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32485. /**
  32486. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32487. * It can add constant keys at begin or end
  32488. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32489. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32490. * @returns the animation group
  32491. */
  32492. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32493. /**
  32494. * Start all animations on given targets
  32495. * @param loop defines if animations must loop
  32496. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32497. * @param from defines the from key (optional)
  32498. * @param to defines the to key (optional)
  32499. * @returns the current animation group
  32500. */
  32501. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32502. /**
  32503. * Pause all animations
  32504. * @returns the animation group
  32505. */
  32506. pause(): AnimationGroup;
  32507. /**
  32508. * Play all animations to initial state
  32509. * This function will start() the animations if they were not started or will restart() them if they were paused
  32510. * @param loop defines if animations must loop
  32511. * @returns the animation group
  32512. */
  32513. play(loop?: boolean): AnimationGroup;
  32514. /**
  32515. * Reset all animations to initial state
  32516. * @returns the animation group
  32517. */
  32518. reset(): AnimationGroup;
  32519. /**
  32520. * Restart animations from key 0
  32521. * @returns the animation group
  32522. */
  32523. restart(): AnimationGroup;
  32524. /**
  32525. * Stop all animations
  32526. * @returns the animation group
  32527. */
  32528. stop(): AnimationGroup;
  32529. /**
  32530. * Set animation weight for all animatables
  32531. * @param weight defines the weight to use
  32532. * @return the animationGroup
  32533. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32534. */
  32535. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32536. /**
  32537. * Synchronize and normalize all animatables with a source animatable
  32538. * @param root defines the root animatable to synchronize with
  32539. * @return the animationGroup
  32540. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32541. */
  32542. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32543. /**
  32544. * Goes to a specific frame in this animation group
  32545. * @param frame the frame number to go to
  32546. * @return the animationGroup
  32547. */
  32548. goToFrame(frame: number): AnimationGroup;
  32549. /**
  32550. * Dispose all associated resources
  32551. */
  32552. dispose(): void;
  32553. private _checkAnimationGroupEnded;
  32554. /**
  32555. * Clone the current animation group and returns a copy
  32556. * @param newName defines the name of the new group
  32557. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32558. * @returns the new aniamtion group
  32559. */
  32560. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32561. /**
  32562. * Serializes the animationGroup to an object
  32563. * @returns Serialized object
  32564. */
  32565. serialize(): any;
  32566. /**
  32567. * Returns a new AnimationGroup object parsed from the source provided.
  32568. * @param parsedAnimationGroup defines the source
  32569. * @param scene defines the scene that will receive the animationGroup
  32570. * @returns a new AnimationGroup
  32571. */
  32572. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32573. /**
  32574. * Returns the string "AnimationGroup"
  32575. * @returns "AnimationGroup"
  32576. */
  32577. getClassName(): string;
  32578. /**
  32579. * Creates a detailled string about the object
  32580. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32581. * @returns a string representing the object
  32582. */
  32583. toString(fullDetails?: boolean): string;
  32584. }
  32585. }
  32586. declare module BABYLON {
  32587. /**
  32588. * Define an interface for all classes that will hold resources
  32589. */
  32590. export interface IDisposable {
  32591. /**
  32592. * Releases all held resources
  32593. */
  32594. dispose(): void;
  32595. }
  32596. /** Interface defining initialization parameters for Scene class */
  32597. export interface SceneOptions {
  32598. /**
  32599. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32600. * It will improve performance when the number of geometries becomes important.
  32601. */
  32602. useGeometryUniqueIdsMap?: boolean;
  32603. /**
  32604. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32605. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32606. */
  32607. useMaterialMeshMap?: boolean;
  32608. /**
  32609. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32610. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32611. */
  32612. useClonedMeshhMap?: boolean;
  32613. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32614. virtual?: boolean;
  32615. }
  32616. /**
  32617. * Represents a scene to be rendered by the engine.
  32618. * @see http://doc.babylonjs.com/features/scene
  32619. */
  32620. export class Scene extends AbstractScene implements IAnimatable {
  32621. /** The fog is deactivated */
  32622. static readonly FOGMODE_NONE: number;
  32623. /** The fog density is following an exponential function */
  32624. static readonly FOGMODE_EXP: number;
  32625. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32626. static readonly FOGMODE_EXP2: number;
  32627. /** The fog density is following a linear function. */
  32628. static readonly FOGMODE_LINEAR: number;
  32629. /**
  32630. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32632. */
  32633. static MinDeltaTime: number;
  32634. /**
  32635. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32636. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32637. */
  32638. static MaxDeltaTime: number;
  32639. /**
  32640. * Factory used to create the default material.
  32641. * @param name The name of the material to create
  32642. * @param scene The scene to create the material for
  32643. * @returns The default material
  32644. */
  32645. static DefaultMaterialFactory(scene: Scene): Material;
  32646. /**
  32647. * Factory used to create the a collision coordinator.
  32648. * @returns The collision coordinator
  32649. */
  32650. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32651. /** @hidden */
  32652. _inputManager: InputManager;
  32653. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32654. cameraToUseForPointers: Nullable<Camera>;
  32655. /** @hidden */
  32656. readonly _isScene: boolean;
  32657. /**
  32658. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32659. */
  32660. autoClear: boolean;
  32661. /**
  32662. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32663. */
  32664. autoClearDepthAndStencil: boolean;
  32665. /**
  32666. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32667. */
  32668. clearColor: Color4;
  32669. /**
  32670. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32671. */
  32672. ambientColor: Color3;
  32673. /**
  32674. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32675. * It should only be one of the following (if not the default embedded one):
  32676. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32677. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32678. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32679. * The material properties need to be setup according to the type of texture in use.
  32680. */
  32681. environmentBRDFTexture: BaseTexture;
  32682. /** @hidden */
  32683. protected _environmentTexture: Nullable<BaseTexture>;
  32684. /**
  32685. * Texture used in all pbr material as the reflection texture.
  32686. * As in the majority of the scene they are the same (exception for multi room and so on),
  32687. * this is easier to reference from here than from all the materials.
  32688. */
  32689. /**
  32690. * Texture used in all pbr material as the reflection texture.
  32691. * As in the majority of the scene they are the same (exception for multi room and so on),
  32692. * this is easier to set here than in all the materials.
  32693. */
  32694. environmentTexture: Nullable<BaseTexture>;
  32695. /** @hidden */
  32696. protected _environmentIntensity: number;
  32697. /**
  32698. * Intensity of the environment in all pbr material.
  32699. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32700. * As in the majority of the scene they are the same (exception for multi room and so on),
  32701. * this is easier to reference from here than from all the materials.
  32702. */
  32703. /**
  32704. * Intensity of the environment in all pbr material.
  32705. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32706. * As in the majority of the scene they are the same (exception for multi room and so on),
  32707. * this is easier to set here than in all the materials.
  32708. */
  32709. environmentIntensity: number;
  32710. /** @hidden */
  32711. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32712. /**
  32713. * Default image processing configuration used either in the rendering
  32714. * Forward main pass or through the imageProcessingPostProcess if present.
  32715. * As in the majority of the scene they are the same (exception for multi camera),
  32716. * this is easier to reference from here than from all the materials and post process.
  32717. *
  32718. * No setter as we it is a shared configuration, you can set the values instead.
  32719. */
  32720. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32721. private _forceWireframe;
  32722. /**
  32723. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32724. */
  32725. forceWireframe: boolean;
  32726. private _forcePointsCloud;
  32727. /**
  32728. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32729. */
  32730. forcePointsCloud: boolean;
  32731. /**
  32732. * Gets or sets the active clipplane 1
  32733. */
  32734. clipPlane: Nullable<Plane>;
  32735. /**
  32736. * Gets or sets the active clipplane 2
  32737. */
  32738. clipPlane2: Nullable<Plane>;
  32739. /**
  32740. * Gets or sets the active clipplane 3
  32741. */
  32742. clipPlane3: Nullable<Plane>;
  32743. /**
  32744. * Gets or sets the active clipplane 4
  32745. */
  32746. clipPlane4: Nullable<Plane>;
  32747. /**
  32748. * Gets or sets a boolean indicating if animations are enabled
  32749. */
  32750. animationsEnabled: boolean;
  32751. private _animationPropertiesOverride;
  32752. /**
  32753. * Gets or sets the animation properties override
  32754. */
  32755. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32756. /**
  32757. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32758. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32759. */
  32760. useConstantAnimationDeltaTime: boolean;
  32761. /**
  32762. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32763. * Please note that it requires to run a ray cast through the scene on every frame
  32764. */
  32765. constantlyUpdateMeshUnderPointer: boolean;
  32766. /**
  32767. * Defines the HTML cursor to use when hovering over interactive elements
  32768. */
  32769. hoverCursor: string;
  32770. /**
  32771. * Defines the HTML default cursor to use (empty by default)
  32772. */
  32773. defaultCursor: string;
  32774. /**
  32775. * This is used to call preventDefault() on pointer down
  32776. * in order to block unwanted artifacts like system double clicks
  32777. */
  32778. preventDefaultOnPointerDown: boolean;
  32779. /**
  32780. * This is used to call preventDefault() on pointer up
  32781. * in order to block unwanted artifacts like system double clicks
  32782. */
  32783. preventDefaultOnPointerUp: boolean;
  32784. /**
  32785. * Gets or sets user defined metadata
  32786. */
  32787. metadata: any;
  32788. /**
  32789. * For internal use only. Please do not use.
  32790. */
  32791. reservedDataStore: any;
  32792. /**
  32793. * Gets the name of the plugin used to load this scene (null by default)
  32794. */
  32795. loadingPluginName: string;
  32796. /**
  32797. * Use this array to add regular expressions used to disable offline support for specific urls
  32798. */
  32799. disableOfflineSupportExceptionRules: RegExp[];
  32800. /**
  32801. * An event triggered when the scene is disposed.
  32802. */
  32803. onDisposeObservable: Observable<Scene>;
  32804. private _onDisposeObserver;
  32805. /** Sets a function to be executed when this scene is disposed. */
  32806. onDispose: () => void;
  32807. /**
  32808. * An event triggered before rendering the scene (right after animations and physics)
  32809. */
  32810. onBeforeRenderObservable: Observable<Scene>;
  32811. private _onBeforeRenderObserver;
  32812. /** Sets a function to be executed before rendering this scene */
  32813. beforeRender: Nullable<() => void>;
  32814. /**
  32815. * An event triggered after rendering the scene
  32816. */
  32817. onAfterRenderObservable: Observable<Scene>;
  32818. /**
  32819. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32820. */
  32821. onAfterRenderCameraObservable: Observable<Camera>;
  32822. private _onAfterRenderObserver;
  32823. /** Sets a function to be executed after rendering this scene */
  32824. afterRender: Nullable<() => void>;
  32825. /**
  32826. * An event triggered before animating the scene
  32827. */
  32828. onBeforeAnimationsObservable: Observable<Scene>;
  32829. /**
  32830. * An event triggered after animations processing
  32831. */
  32832. onAfterAnimationsObservable: Observable<Scene>;
  32833. /**
  32834. * An event triggered before draw calls are ready to be sent
  32835. */
  32836. onBeforeDrawPhaseObservable: Observable<Scene>;
  32837. /**
  32838. * An event triggered after draw calls have been sent
  32839. */
  32840. onAfterDrawPhaseObservable: Observable<Scene>;
  32841. /**
  32842. * An event triggered when the scene is ready
  32843. */
  32844. onReadyObservable: Observable<Scene>;
  32845. /**
  32846. * An event triggered before rendering a camera
  32847. */
  32848. onBeforeCameraRenderObservable: Observable<Camera>;
  32849. private _onBeforeCameraRenderObserver;
  32850. /** Sets a function to be executed before rendering a camera*/
  32851. beforeCameraRender: () => void;
  32852. /**
  32853. * An event triggered after rendering a camera
  32854. */
  32855. onAfterCameraRenderObservable: Observable<Camera>;
  32856. private _onAfterCameraRenderObserver;
  32857. /** Sets a function to be executed after rendering a camera*/
  32858. afterCameraRender: () => void;
  32859. /**
  32860. * An event triggered when active meshes evaluation is about to start
  32861. */
  32862. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32863. /**
  32864. * An event triggered when active meshes evaluation is done
  32865. */
  32866. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32867. /**
  32868. * An event triggered when particles rendering is about to start
  32869. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32870. */
  32871. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32872. /**
  32873. * An event triggered when particles rendering is done
  32874. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32875. */
  32876. onAfterParticlesRenderingObservable: Observable<Scene>;
  32877. /**
  32878. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32879. */
  32880. onDataLoadedObservable: Observable<Scene>;
  32881. /**
  32882. * An event triggered when a camera is created
  32883. */
  32884. onNewCameraAddedObservable: Observable<Camera>;
  32885. /**
  32886. * An event triggered when a camera is removed
  32887. */
  32888. onCameraRemovedObservable: Observable<Camera>;
  32889. /**
  32890. * An event triggered when a light is created
  32891. */
  32892. onNewLightAddedObservable: Observable<Light>;
  32893. /**
  32894. * An event triggered when a light is removed
  32895. */
  32896. onLightRemovedObservable: Observable<Light>;
  32897. /**
  32898. * An event triggered when a geometry is created
  32899. */
  32900. onNewGeometryAddedObservable: Observable<Geometry>;
  32901. /**
  32902. * An event triggered when a geometry is removed
  32903. */
  32904. onGeometryRemovedObservable: Observable<Geometry>;
  32905. /**
  32906. * An event triggered when a transform node is created
  32907. */
  32908. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32909. /**
  32910. * An event triggered when a transform node is removed
  32911. */
  32912. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32913. /**
  32914. * An event triggered when a mesh is created
  32915. */
  32916. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32917. /**
  32918. * An event triggered when a mesh is removed
  32919. */
  32920. onMeshRemovedObservable: Observable<AbstractMesh>;
  32921. /**
  32922. * An event triggered when a skeleton is created
  32923. */
  32924. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32925. /**
  32926. * An event triggered when a skeleton is removed
  32927. */
  32928. onSkeletonRemovedObservable: Observable<Skeleton>;
  32929. /**
  32930. * An event triggered when a material is created
  32931. */
  32932. onNewMaterialAddedObservable: Observable<Material>;
  32933. /**
  32934. * An event triggered when a material is removed
  32935. */
  32936. onMaterialRemovedObservable: Observable<Material>;
  32937. /**
  32938. * An event triggered when a texture is created
  32939. */
  32940. onNewTextureAddedObservable: Observable<BaseTexture>;
  32941. /**
  32942. * An event triggered when a texture is removed
  32943. */
  32944. onTextureRemovedObservable: Observable<BaseTexture>;
  32945. /**
  32946. * An event triggered when render targets are about to be rendered
  32947. * Can happen multiple times per frame.
  32948. */
  32949. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32950. /**
  32951. * An event triggered when render targets were rendered.
  32952. * Can happen multiple times per frame.
  32953. */
  32954. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32955. /**
  32956. * An event triggered before calculating deterministic simulation step
  32957. */
  32958. onBeforeStepObservable: Observable<Scene>;
  32959. /**
  32960. * An event triggered after calculating deterministic simulation step
  32961. */
  32962. onAfterStepObservable: Observable<Scene>;
  32963. /**
  32964. * An event triggered when the activeCamera property is updated
  32965. */
  32966. onActiveCameraChanged: Observable<Scene>;
  32967. /**
  32968. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32969. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32970. * 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)
  32971. */
  32972. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32973. /**
  32974. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32975. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32976. * 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)
  32977. */
  32978. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32979. /**
  32980. * This Observable will when a mesh has been imported into the scene.
  32981. */
  32982. onMeshImportedObservable: Observable<AbstractMesh>;
  32983. /**
  32984. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32985. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32986. */
  32987. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32988. /** @hidden */
  32989. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32990. /**
  32991. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32992. */
  32993. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32994. /**
  32995. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32996. */
  32997. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32998. /**
  32999. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33000. */
  33001. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33002. /** Callback called when a pointer move is detected */
  33003. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33004. /** Callback called when a pointer down is detected */
  33005. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33006. /** Callback called when a pointer up is detected */
  33007. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33008. /** Callback called when a pointer pick is detected */
  33009. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33010. /**
  33011. * 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).
  33012. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33013. */
  33014. onPrePointerObservable: Observable<PointerInfoPre>;
  33015. /**
  33016. * Observable event triggered each time an input event is received from the rendering canvas
  33017. */
  33018. onPointerObservable: Observable<PointerInfo>;
  33019. /**
  33020. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33021. */
  33022. readonly unTranslatedPointer: Vector2;
  33023. /**
  33024. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33025. */
  33026. static DragMovementThreshold: number;
  33027. /**
  33028. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33029. */
  33030. static LongPressDelay: number;
  33031. /**
  33032. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33033. */
  33034. static DoubleClickDelay: number;
  33035. /** If you need to check double click without raising a single click at first click, enable this flag */
  33036. static ExclusiveDoubleClickMode: boolean;
  33037. /** @hidden */
  33038. _mirroredCameraPosition: Nullable<Vector3>;
  33039. /**
  33040. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33041. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33042. */
  33043. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33044. /**
  33045. * Observable event triggered each time an keyboard event is received from the hosting window
  33046. */
  33047. onKeyboardObservable: Observable<KeyboardInfo>;
  33048. private _useRightHandedSystem;
  33049. /**
  33050. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33051. */
  33052. useRightHandedSystem: boolean;
  33053. private _timeAccumulator;
  33054. private _currentStepId;
  33055. private _currentInternalStep;
  33056. /**
  33057. * Sets the step Id used by deterministic lock step
  33058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33059. * @param newStepId defines the step Id
  33060. */
  33061. setStepId(newStepId: number): void;
  33062. /**
  33063. * Gets the step Id used by deterministic lock step
  33064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33065. * @returns the step Id
  33066. */
  33067. getStepId(): number;
  33068. /**
  33069. * Gets the internal step used by deterministic lock step
  33070. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33071. * @returns the internal step
  33072. */
  33073. getInternalStep(): number;
  33074. private _fogEnabled;
  33075. /**
  33076. * Gets or sets a boolean indicating if fog is enabled on this scene
  33077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33078. * (Default is true)
  33079. */
  33080. fogEnabled: boolean;
  33081. private _fogMode;
  33082. /**
  33083. * Gets or sets the fog mode to use
  33084. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33085. * | mode | value |
  33086. * | --- | --- |
  33087. * | FOGMODE_NONE | 0 |
  33088. * | FOGMODE_EXP | 1 |
  33089. * | FOGMODE_EXP2 | 2 |
  33090. * | FOGMODE_LINEAR | 3 |
  33091. */
  33092. fogMode: number;
  33093. /**
  33094. * Gets or sets the fog color to use
  33095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33096. * (Default is Color3(0.2, 0.2, 0.3))
  33097. */
  33098. fogColor: Color3;
  33099. /**
  33100. * Gets or sets the fog density to use
  33101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33102. * (Default is 0.1)
  33103. */
  33104. fogDensity: number;
  33105. /**
  33106. * Gets or sets the fog start distance to use
  33107. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33108. * (Default is 0)
  33109. */
  33110. fogStart: number;
  33111. /**
  33112. * Gets or sets the fog end distance to use
  33113. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33114. * (Default is 1000)
  33115. */
  33116. fogEnd: number;
  33117. private _shadowsEnabled;
  33118. /**
  33119. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33120. */
  33121. shadowsEnabled: boolean;
  33122. private _lightsEnabled;
  33123. /**
  33124. * Gets or sets a boolean indicating if lights are enabled on this scene
  33125. */
  33126. lightsEnabled: boolean;
  33127. /** All of the active cameras added to this scene. */
  33128. activeCameras: Camera[];
  33129. /** @hidden */
  33130. _activeCamera: Nullable<Camera>;
  33131. /** Gets or sets the current active camera */
  33132. activeCamera: Nullable<Camera>;
  33133. private _defaultMaterial;
  33134. /** The default material used on meshes when no material is affected */
  33135. /** The default material used on meshes when no material is affected */
  33136. defaultMaterial: Material;
  33137. private _texturesEnabled;
  33138. /**
  33139. * Gets or sets a boolean indicating if textures are enabled on this scene
  33140. */
  33141. texturesEnabled: boolean;
  33142. /**
  33143. * Gets or sets a boolean indicating if particles are enabled on this scene
  33144. */
  33145. particlesEnabled: boolean;
  33146. /**
  33147. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33148. */
  33149. spritesEnabled: boolean;
  33150. private _skeletonsEnabled;
  33151. /**
  33152. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33153. */
  33154. skeletonsEnabled: boolean;
  33155. /**
  33156. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33157. */
  33158. lensFlaresEnabled: boolean;
  33159. /**
  33160. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33161. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33162. */
  33163. collisionsEnabled: boolean;
  33164. private _collisionCoordinator;
  33165. /** @hidden */
  33166. readonly collisionCoordinator: ICollisionCoordinator;
  33167. /**
  33168. * Defines the gravity applied to this scene (used only for collisions)
  33169. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33170. */
  33171. gravity: Vector3;
  33172. /**
  33173. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33174. */
  33175. postProcessesEnabled: boolean;
  33176. /**
  33177. * The list of postprocesses added to the scene
  33178. */
  33179. postProcesses: PostProcess[];
  33180. /**
  33181. * Gets the current postprocess manager
  33182. */
  33183. postProcessManager: PostProcessManager;
  33184. /**
  33185. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33186. */
  33187. renderTargetsEnabled: boolean;
  33188. /**
  33189. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33190. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33191. */
  33192. dumpNextRenderTargets: boolean;
  33193. /**
  33194. * The list of user defined render targets added to the scene
  33195. */
  33196. customRenderTargets: RenderTargetTexture[];
  33197. /**
  33198. * Defines if texture loading must be delayed
  33199. * If true, textures will only be loaded when they need to be rendered
  33200. */
  33201. useDelayedTextureLoading: boolean;
  33202. /**
  33203. * Gets the list of meshes imported to the scene through SceneLoader
  33204. */
  33205. importedMeshesFiles: String[];
  33206. /**
  33207. * Gets or sets a boolean indicating if probes are enabled on this scene
  33208. */
  33209. probesEnabled: boolean;
  33210. /**
  33211. * Gets or sets the current offline provider to use to store scene data
  33212. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33213. */
  33214. offlineProvider: IOfflineProvider;
  33215. /**
  33216. * Gets or sets the action manager associated with the scene
  33217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33218. */
  33219. actionManager: AbstractActionManager;
  33220. private _meshesForIntersections;
  33221. /**
  33222. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33223. */
  33224. proceduralTexturesEnabled: boolean;
  33225. private _engine;
  33226. private _totalVertices;
  33227. /** @hidden */
  33228. _activeIndices: PerfCounter;
  33229. /** @hidden */
  33230. _activeParticles: PerfCounter;
  33231. /** @hidden */
  33232. _activeBones: PerfCounter;
  33233. private _animationRatio;
  33234. /** @hidden */
  33235. _animationTimeLast: number;
  33236. /** @hidden */
  33237. _animationTime: number;
  33238. /**
  33239. * Gets or sets a general scale for animation speed
  33240. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33241. */
  33242. animationTimeScale: number;
  33243. /** @hidden */
  33244. _cachedMaterial: Nullable<Material>;
  33245. /** @hidden */
  33246. _cachedEffect: Nullable<Effect>;
  33247. /** @hidden */
  33248. _cachedVisibility: Nullable<number>;
  33249. private _renderId;
  33250. private _frameId;
  33251. private _executeWhenReadyTimeoutId;
  33252. private _intermediateRendering;
  33253. private _viewUpdateFlag;
  33254. private _projectionUpdateFlag;
  33255. /** @hidden */
  33256. _toBeDisposed: Nullable<IDisposable>[];
  33257. private _activeRequests;
  33258. /** @hidden */
  33259. _pendingData: any[];
  33260. private _isDisposed;
  33261. /**
  33262. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33263. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33264. */
  33265. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33266. private _activeMeshes;
  33267. private _processedMaterials;
  33268. private _renderTargets;
  33269. /** @hidden */
  33270. _activeParticleSystems: SmartArray<IParticleSystem>;
  33271. private _activeSkeletons;
  33272. private _softwareSkinnedMeshes;
  33273. private _renderingManager;
  33274. /** @hidden */
  33275. _activeAnimatables: Animatable[];
  33276. private _transformMatrix;
  33277. private _sceneUbo;
  33278. /** @hidden */
  33279. _viewMatrix: Matrix;
  33280. private _projectionMatrix;
  33281. /** @hidden */
  33282. _forcedViewPosition: Nullable<Vector3>;
  33283. /** @hidden */
  33284. _frustumPlanes: Plane[];
  33285. /**
  33286. * Gets the list of frustum planes (built from the active camera)
  33287. */
  33288. readonly frustumPlanes: Plane[];
  33289. /**
  33290. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33291. * This is useful if there are more lights that the maximum simulteanous authorized
  33292. */
  33293. requireLightSorting: boolean;
  33294. /** @hidden */
  33295. readonly useMaterialMeshMap: boolean;
  33296. /** @hidden */
  33297. readonly useClonedMeshhMap: boolean;
  33298. private _externalData;
  33299. private _uid;
  33300. /**
  33301. * @hidden
  33302. * Backing store of defined scene components.
  33303. */
  33304. _components: ISceneComponent[];
  33305. /**
  33306. * @hidden
  33307. * Backing store of defined scene components.
  33308. */
  33309. _serializableComponents: ISceneSerializableComponent[];
  33310. /**
  33311. * List of components to register on the next registration step.
  33312. */
  33313. private _transientComponents;
  33314. /**
  33315. * Registers the transient components if needed.
  33316. */
  33317. private _registerTransientComponents;
  33318. /**
  33319. * @hidden
  33320. * Add a component to the scene.
  33321. * Note that the ccomponent could be registered on th next frame if this is called after
  33322. * the register component stage.
  33323. * @param component Defines the component to add to the scene
  33324. */
  33325. _addComponent(component: ISceneComponent): void;
  33326. /**
  33327. * @hidden
  33328. * Gets a component from the scene.
  33329. * @param name defines the name of the component to retrieve
  33330. * @returns the component or null if not present
  33331. */
  33332. _getComponent(name: string): Nullable<ISceneComponent>;
  33333. /**
  33334. * @hidden
  33335. * Defines the actions happening before camera updates.
  33336. */
  33337. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33338. /**
  33339. * @hidden
  33340. * Defines the actions happening before clear the canvas.
  33341. */
  33342. _beforeClearStage: Stage<SimpleStageAction>;
  33343. /**
  33344. * @hidden
  33345. * Defines the actions when collecting render targets for the frame.
  33346. */
  33347. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33348. /**
  33349. * @hidden
  33350. * Defines the actions happening for one camera in the frame.
  33351. */
  33352. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33353. /**
  33354. * @hidden
  33355. * Defines the actions happening during the per mesh ready checks.
  33356. */
  33357. _isReadyForMeshStage: Stage<MeshStageAction>;
  33358. /**
  33359. * @hidden
  33360. * Defines the actions happening before evaluate active mesh checks.
  33361. */
  33362. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33363. /**
  33364. * @hidden
  33365. * Defines the actions happening during the evaluate sub mesh checks.
  33366. */
  33367. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33368. /**
  33369. * @hidden
  33370. * Defines the actions happening during the active mesh stage.
  33371. */
  33372. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33373. /**
  33374. * @hidden
  33375. * Defines the actions happening during the per camera render target step.
  33376. */
  33377. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33378. /**
  33379. * @hidden
  33380. * Defines the actions happening just before the active camera is drawing.
  33381. */
  33382. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33383. /**
  33384. * @hidden
  33385. * Defines the actions happening just before a render target is drawing.
  33386. */
  33387. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33388. /**
  33389. * @hidden
  33390. * Defines the actions happening just before a rendering group is drawing.
  33391. */
  33392. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33393. /**
  33394. * @hidden
  33395. * Defines the actions happening just before a mesh is drawing.
  33396. */
  33397. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33398. /**
  33399. * @hidden
  33400. * Defines the actions happening just after a mesh has been drawn.
  33401. */
  33402. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33403. /**
  33404. * @hidden
  33405. * Defines the actions happening just after a rendering group has been drawn.
  33406. */
  33407. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33408. /**
  33409. * @hidden
  33410. * Defines the actions happening just after the active camera has been drawn.
  33411. */
  33412. _afterCameraDrawStage: Stage<CameraStageAction>;
  33413. /**
  33414. * @hidden
  33415. * Defines the actions happening just after a render target has been drawn.
  33416. */
  33417. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33418. /**
  33419. * @hidden
  33420. * Defines the actions happening just after rendering all cameras and computing intersections.
  33421. */
  33422. _afterRenderStage: Stage<SimpleStageAction>;
  33423. /**
  33424. * @hidden
  33425. * Defines the actions happening when a pointer move event happens.
  33426. */
  33427. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33428. /**
  33429. * @hidden
  33430. * Defines the actions happening when a pointer down event happens.
  33431. */
  33432. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33433. /**
  33434. * @hidden
  33435. * Defines the actions happening when a pointer up event happens.
  33436. */
  33437. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33438. /**
  33439. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33440. */
  33441. private geometriesByUniqueId;
  33442. /**
  33443. * Creates a new Scene
  33444. * @param engine defines the engine to use to render this scene
  33445. * @param options defines the scene options
  33446. */
  33447. constructor(engine: Engine, options?: SceneOptions);
  33448. /**
  33449. * Gets a string idenfifying the name of the class
  33450. * @returns "Scene" string
  33451. */
  33452. getClassName(): string;
  33453. private _defaultMeshCandidates;
  33454. /**
  33455. * @hidden
  33456. */
  33457. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33458. private _defaultSubMeshCandidates;
  33459. /**
  33460. * @hidden
  33461. */
  33462. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33463. /**
  33464. * Sets the default candidate providers for the scene.
  33465. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33466. * and getCollidingSubMeshCandidates to their default function
  33467. */
  33468. setDefaultCandidateProviders(): void;
  33469. /**
  33470. * Gets the mesh that is currently under the pointer
  33471. */
  33472. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33473. /**
  33474. * Gets or sets the current on-screen X position of the pointer
  33475. */
  33476. pointerX: number;
  33477. /**
  33478. * Gets or sets the current on-screen Y position of the pointer
  33479. */
  33480. pointerY: number;
  33481. /**
  33482. * Gets the cached material (ie. the latest rendered one)
  33483. * @returns the cached material
  33484. */
  33485. getCachedMaterial(): Nullable<Material>;
  33486. /**
  33487. * Gets the cached effect (ie. the latest rendered one)
  33488. * @returns the cached effect
  33489. */
  33490. getCachedEffect(): Nullable<Effect>;
  33491. /**
  33492. * Gets the cached visibility state (ie. the latest rendered one)
  33493. * @returns the cached visibility state
  33494. */
  33495. getCachedVisibility(): Nullable<number>;
  33496. /**
  33497. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33498. * @param material defines the current material
  33499. * @param effect defines the current effect
  33500. * @param visibility defines the current visibility state
  33501. * @returns true if one parameter is not cached
  33502. */
  33503. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33504. /**
  33505. * Gets the engine associated with the scene
  33506. * @returns an Engine
  33507. */
  33508. getEngine(): Engine;
  33509. /**
  33510. * Gets the total number of vertices rendered per frame
  33511. * @returns the total number of vertices rendered per frame
  33512. */
  33513. getTotalVertices(): number;
  33514. /**
  33515. * Gets the performance counter for total vertices
  33516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33517. */
  33518. readonly totalVerticesPerfCounter: PerfCounter;
  33519. /**
  33520. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33521. * @returns the total number of active indices rendered per frame
  33522. */
  33523. getActiveIndices(): number;
  33524. /**
  33525. * Gets the performance counter for active indices
  33526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33527. */
  33528. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33529. /**
  33530. * Gets the total number of active particles rendered per frame
  33531. * @returns the total number of active particles rendered per frame
  33532. */
  33533. getActiveParticles(): number;
  33534. /**
  33535. * Gets the performance counter for active particles
  33536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33537. */
  33538. readonly activeParticlesPerfCounter: PerfCounter;
  33539. /**
  33540. * Gets the total number of active bones rendered per frame
  33541. * @returns the total number of active bones rendered per frame
  33542. */
  33543. getActiveBones(): number;
  33544. /**
  33545. * Gets the performance counter for active bones
  33546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33547. */
  33548. readonly activeBonesPerfCounter: PerfCounter;
  33549. /**
  33550. * Gets the array of active meshes
  33551. * @returns an array of AbstractMesh
  33552. */
  33553. getActiveMeshes(): SmartArray<AbstractMesh>;
  33554. /**
  33555. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33556. * @returns a number
  33557. */
  33558. getAnimationRatio(): number;
  33559. /**
  33560. * Gets an unique Id for the current render phase
  33561. * @returns a number
  33562. */
  33563. getRenderId(): number;
  33564. /**
  33565. * Gets an unique Id for the current frame
  33566. * @returns a number
  33567. */
  33568. getFrameId(): number;
  33569. /** Call this function if you want to manually increment the render Id*/
  33570. incrementRenderId(): void;
  33571. private _createUbo;
  33572. /**
  33573. * Use this method to simulate a pointer move on a mesh
  33574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33577. * @returns the current scene
  33578. */
  33579. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33580. /**
  33581. * Use this method to simulate a pointer down on a mesh
  33582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33585. * @returns the current scene
  33586. */
  33587. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33588. /**
  33589. * Use this method to simulate a pointer up on a mesh
  33590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33593. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33594. * @returns the current scene
  33595. */
  33596. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33597. /**
  33598. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33599. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33600. * @returns true if the pointer was captured
  33601. */
  33602. isPointerCaptured(pointerId?: number): boolean;
  33603. /**
  33604. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33605. * @param attachUp defines if you want to attach events to pointerup
  33606. * @param attachDown defines if you want to attach events to pointerdown
  33607. * @param attachMove defines if you want to attach events to pointermove
  33608. */
  33609. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33610. /** Detaches all event handlers*/
  33611. detachControl(): void;
  33612. /**
  33613. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33614. * Delay loaded resources are not taking in account
  33615. * @return true if all required resources are ready
  33616. */
  33617. isReady(): boolean;
  33618. /** Resets all cached information relative to material (including effect and visibility) */
  33619. resetCachedMaterial(): void;
  33620. /**
  33621. * Registers a function to be called before every frame render
  33622. * @param func defines the function to register
  33623. */
  33624. registerBeforeRender(func: () => void): void;
  33625. /**
  33626. * Unregisters a function called before every frame render
  33627. * @param func defines the function to unregister
  33628. */
  33629. unregisterBeforeRender(func: () => void): void;
  33630. /**
  33631. * Registers a function to be called after every frame render
  33632. * @param func defines the function to register
  33633. */
  33634. registerAfterRender(func: () => void): void;
  33635. /**
  33636. * Unregisters a function called after every frame render
  33637. * @param func defines the function to unregister
  33638. */
  33639. unregisterAfterRender(func: () => void): void;
  33640. private _executeOnceBeforeRender;
  33641. /**
  33642. * The provided function will run before render once and will be disposed afterwards.
  33643. * A timeout delay can be provided so that the function will be executed in N ms.
  33644. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33645. * @param func The function to be executed.
  33646. * @param timeout optional delay in ms
  33647. */
  33648. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33649. /** @hidden */
  33650. _addPendingData(data: any): void;
  33651. /** @hidden */
  33652. _removePendingData(data: any): void;
  33653. /**
  33654. * Returns the number of items waiting to be loaded
  33655. * @returns the number of items waiting to be loaded
  33656. */
  33657. getWaitingItemsCount(): number;
  33658. /**
  33659. * Returns a boolean indicating if the scene is still loading data
  33660. */
  33661. readonly isLoading: boolean;
  33662. /**
  33663. * Registers a function to be executed when the scene is ready
  33664. * @param {Function} func - the function to be executed
  33665. */
  33666. executeWhenReady(func: () => void): void;
  33667. /**
  33668. * Returns a promise that resolves when the scene is ready
  33669. * @returns A promise that resolves when the scene is ready
  33670. */
  33671. whenReadyAsync(): Promise<void>;
  33672. /** @hidden */
  33673. _checkIsReady(): void;
  33674. /**
  33675. * Gets all animatable attached to the scene
  33676. */
  33677. readonly animatables: Animatable[];
  33678. /**
  33679. * Resets the last animation time frame.
  33680. * Useful to override when animations start running when loading a scene for the first time.
  33681. */
  33682. resetLastAnimationTimeFrame(): void;
  33683. /**
  33684. * Gets the current view matrix
  33685. * @returns a Matrix
  33686. */
  33687. getViewMatrix(): Matrix;
  33688. /**
  33689. * Gets the current projection matrix
  33690. * @returns a Matrix
  33691. */
  33692. getProjectionMatrix(): Matrix;
  33693. /**
  33694. * Gets the current transform matrix
  33695. * @returns a Matrix made of View * Projection
  33696. */
  33697. getTransformMatrix(): Matrix;
  33698. /**
  33699. * Sets the current transform matrix
  33700. * @param viewL defines the View matrix to use
  33701. * @param projectionL defines the Projection matrix to use
  33702. * @param viewR defines the right View matrix to use (if provided)
  33703. * @param projectionR defines the right Projection matrix to use (if provided)
  33704. */
  33705. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33706. /**
  33707. * Gets the uniform buffer used to store scene data
  33708. * @returns a UniformBuffer
  33709. */
  33710. getSceneUniformBuffer(): UniformBuffer;
  33711. /**
  33712. * Gets an unique (relatively to the current scene) Id
  33713. * @returns an unique number for the scene
  33714. */
  33715. getUniqueId(): number;
  33716. /**
  33717. * Add a mesh to the list of scene's meshes
  33718. * @param newMesh defines the mesh to add
  33719. * @param recursive if all child meshes should also be added to the scene
  33720. */
  33721. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33722. /**
  33723. * Remove a mesh for the list of scene's meshes
  33724. * @param toRemove defines the mesh to remove
  33725. * @param recursive if all child meshes should also be removed from the scene
  33726. * @returns the index where the mesh was in the mesh list
  33727. */
  33728. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33729. /**
  33730. * Add a transform node to the list of scene's transform nodes
  33731. * @param newTransformNode defines the transform node to add
  33732. */
  33733. addTransformNode(newTransformNode: TransformNode): void;
  33734. /**
  33735. * Remove a transform node for the list of scene's transform nodes
  33736. * @param toRemove defines the transform node to remove
  33737. * @returns the index where the transform node was in the transform node list
  33738. */
  33739. removeTransformNode(toRemove: TransformNode): number;
  33740. /**
  33741. * Remove a skeleton for the list of scene's skeletons
  33742. * @param toRemove defines the skeleton to remove
  33743. * @returns the index where the skeleton was in the skeleton list
  33744. */
  33745. removeSkeleton(toRemove: Skeleton): number;
  33746. /**
  33747. * Remove a morph target for the list of scene's morph targets
  33748. * @param toRemove defines the morph target to remove
  33749. * @returns the index where the morph target was in the morph target list
  33750. */
  33751. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33752. /**
  33753. * Remove a light for the list of scene's lights
  33754. * @param toRemove defines the light to remove
  33755. * @returns the index where the light was in the light list
  33756. */
  33757. removeLight(toRemove: Light): number;
  33758. /**
  33759. * Remove a camera for the list of scene's cameras
  33760. * @param toRemove defines the camera to remove
  33761. * @returns the index where the camera was in the camera list
  33762. */
  33763. removeCamera(toRemove: Camera): number;
  33764. /**
  33765. * Remove a particle system for the list of scene's particle systems
  33766. * @param toRemove defines the particle system to remove
  33767. * @returns the index where the particle system was in the particle system list
  33768. */
  33769. removeParticleSystem(toRemove: IParticleSystem): number;
  33770. /**
  33771. * Remove a animation for the list of scene's animations
  33772. * @param toRemove defines the animation to remove
  33773. * @returns the index where the animation was in the animation list
  33774. */
  33775. removeAnimation(toRemove: Animation): number;
  33776. /**
  33777. * Will stop the animation of the given target
  33778. * @param target - the target
  33779. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33780. * @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)
  33781. */
  33782. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33783. /**
  33784. * Removes the given animation group from this scene.
  33785. * @param toRemove The animation group to remove
  33786. * @returns The index of the removed animation group
  33787. */
  33788. removeAnimationGroup(toRemove: AnimationGroup): number;
  33789. /**
  33790. * Removes the given multi-material from this scene.
  33791. * @param toRemove The multi-material to remove
  33792. * @returns The index of the removed multi-material
  33793. */
  33794. removeMultiMaterial(toRemove: MultiMaterial): number;
  33795. /**
  33796. * Removes the given material from this scene.
  33797. * @param toRemove The material to remove
  33798. * @returns The index of the removed material
  33799. */
  33800. removeMaterial(toRemove: Material): number;
  33801. /**
  33802. * Removes the given action manager from this scene.
  33803. * @param toRemove The action manager to remove
  33804. * @returns The index of the removed action manager
  33805. */
  33806. removeActionManager(toRemove: AbstractActionManager): number;
  33807. /**
  33808. * Removes the given texture from this scene.
  33809. * @param toRemove The texture to remove
  33810. * @returns The index of the removed texture
  33811. */
  33812. removeTexture(toRemove: BaseTexture): number;
  33813. /**
  33814. * Adds the given light to this scene
  33815. * @param newLight The light to add
  33816. */
  33817. addLight(newLight: Light): void;
  33818. /**
  33819. * Sorts the list list based on light priorities
  33820. */
  33821. sortLightsByPriority(): void;
  33822. /**
  33823. * Adds the given camera to this scene
  33824. * @param newCamera The camera to add
  33825. */
  33826. addCamera(newCamera: Camera): void;
  33827. /**
  33828. * Adds the given skeleton to this scene
  33829. * @param newSkeleton The skeleton to add
  33830. */
  33831. addSkeleton(newSkeleton: Skeleton): void;
  33832. /**
  33833. * Adds the given particle system to this scene
  33834. * @param newParticleSystem The particle system to add
  33835. */
  33836. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33837. /**
  33838. * Adds the given animation to this scene
  33839. * @param newAnimation The animation to add
  33840. */
  33841. addAnimation(newAnimation: Animation): void;
  33842. /**
  33843. * Adds the given animation group to this scene.
  33844. * @param newAnimationGroup The animation group to add
  33845. */
  33846. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33847. /**
  33848. * Adds the given multi-material to this scene
  33849. * @param newMultiMaterial The multi-material to add
  33850. */
  33851. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33852. /**
  33853. * Adds the given material to this scene
  33854. * @param newMaterial The material to add
  33855. */
  33856. addMaterial(newMaterial: Material): void;
  33857. /**
  33858. * Adds the given morph target to this scene
  33859. * @param newMorphTargetManager The morph target to add
  33860. */
  33861. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33862. /**
  33863. * Adds the given geometry to this scene
  33864. * @param newGeometry The geometry to add
  33865. */
  33866. addGeometry(newGeometry: Geometry): void;
  33867. /**
  33868. * Adds the given action manager to this scene
  33869. * @param newActionManager The action manager to add
  33870. */
  33871. addActionManager(newActionManager: AbstractActionManager): void;
  33872. /**
  33873. * Adds the given texture to this scene.
  33874. * @param newTexture The texture to add
  33875. */
  33876. addTexture(newTexture: BaseTexture): void;
  33877. /**
  33878. * Switch active camera
  33879. * @param newCamera defines the new active camera
  33880. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33881. */
  33882. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33883. /**
  33884. * sets the active camera of the scene using its ID
  33885. * @param id defines the camera's ID
  33886. * @return the new active camera or null if none found.
  33887. */
  33888. setActiveCameraByID(id: string): Nullable<Camera>;
  33889. /**
  33890. * sets the active camera of the scene using its name
  33891. * @param name defines the camera's name
  33892. * @returns the new active camera or null if none found.
  33893. */
  33894. setActiveCameraByName(name: string): Nullable<Camera>;
  33895. /**
  33896. * get an animation group using its name
  33897. * @param name defines the material's name
  33898. * @return the animation group or null if none found.
  33899. */
  33900. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33901. /**
  33902. * Get a material using its unique id
  33903. * @param uniqueId defines the material's unique id
  33904. * @return the material or null if none found.
  33905. */
  33906. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33907. /**
  33908. * get a material using its id
  33909. * @param id defines the material's ID
  33910. * @return the material or null if none found.
  33911. */
  33912. getMaterialByID(id: string): Nullable<Material>;
  33913. /**
  33914. * Gets a the last added material using a given id
  33915. * @param id defines the material's ID
  33916. * @return the last material with the given id or null if none found.
  33917. */
  33918. getLastMaterialByID(id: string): Nullable<Material>;
  33919. /**
  33920. * Gets a material using its name
  33921. * @param name defines the material's name
  33922. * @return the material or null if none found.
  33923. */
  33924. getMaterialByName(name: string): Nullable<Material>;
  33925. /**
  33926. * Get a texture using its unique id
  33927. * @param uniqueId defines the texture's unique id
  33928. * @return the texture or null if none found.
  33929. */
  33930. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33931. /**
  33932. * Gets a camera using its id
  33933. * @param id defines the id to look for
  33934. * @returns the camera or null if not found
  33935. */
  33936. getCameraByID(id: string): Nullable<Camera>;
  33937. /**
  33938. * Gets a camera using its unique id
  33939. * @param uniqueId defines the unique id to look for
  33940. * @returns the camera or null if not found
  33941. */
  33942. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33943. /**
  33944. * Gets a camera using its name
  33945. * @param name defines the camera's name
  33946. * @return the camera or null if none found.
  33947. */
  33948. getCameraByName(name: string): Nullable<Camera>;
  33949. /**
  33950. * Gets a bone using its id
  33951. * @param id defines the bone's id
  33952. * @return the bone or null if not found
  33953. */
  33954. getBoneByID(id: string): Nullable<Bone>;
  33955. /**
  33956. * Gets a bone using its id
  33957. * @param name defines the bone's name
  33958. * @return the bone or null if not found
  33959. */
  33960. getBoneByName(name: string): Nullable<Bone>;
  33961. /**
  33962. * Gets a light node using its name
  33963. * @param name defines the the light's name
  33964. * @return the light or null if none found.
  33965. */
  33966. getLightByName(name: string): Nullable<Light>;
  33967. /**
  33968. * Gets a light node using its id
  33969. * @param id defines the light's id
  33970. * @return the light or null if none found.
  33971. */
  33972. getLightByID(id: string): Nullable<Light>;
  33973. /**
  33974. * Gets a light node using its scene-generated unique ID
  33975. * @param uniqueId defines the light's unique id
  33976. * @return the light or null if none found.
  33977. */
  33978. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33979. /**
  33980. * Gets a particle system by id
  33981. * @param id defines the particle system id
  33982. * @return the corresponding system or null if none found
  33983. */
  33984. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33985. /**
  33986. * Gets a geometry using its ID
  33987. * @param id defines the geometry's id
  33988. * @return the geometry or null if none found.
  33989. */
  33990. getGeometryByID(id: string): Nullable<Geometry>;
  33991. private _getGeometryByUniqueID;
  33992. /**
  33993. * Add a new geometry to this scene
  33994. * @param geometry defines the geometry to be added to the scene.
  33995. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33996. * @return a boolean defining if the geometry was added or not
  33997. */
  33998. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33999. /**
  34000. * Removes an existing geometry
  34001. * @param geometry defines the geometry to be removed from the scene
  34002. * @return a boolean defining if the geometry was removed or not
  34003. */
  34004. removeGeometry(geometry: Geometry): boolean;
  34005. /**
  34006. * Gets the list of geometries attached to the scene
  34007. * @returns an array of Geometry
  34008. */
  34009. getGeometries(): Geometry[];
  34010. /**
  34011. * Gets the first added mesh found of a given ID
  34012. * @param id defines the id to search for
  34013. * @return the mesh found or null if not found at all
  34014. */
  34015. getMeshByID(id: string): Nullable<AbstractMesh>;
  34016. /**
  34017. * Gets a list of meshes using their id
  34018. * @param id defines the id to search for
  34019. * @returns a list of meshes
  34020. */
  34021. getMeshesByID(id: string): Array<AbstractMesh>;
  34022. /**
  34023. * Gets the first added transform node found of a given ID
  34024. * @param id defines the id to search for
  34025. * @return the found transform node or null if not found at all.
  34026. */
  34027. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34028. /**
  34029. * Gets a transform node with its auto-generated unique id
  34030. * @param uniqueId efines the unique id to search for
  34031. * @return the found transform node or null if not found at all.
  34032. */
  34033. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34034. /**
  34035. * Gets a list of transform nodes using their id
  34036. * @param id defines the id to search for
  34037. * @returns a list of transform nodes
  34038. */
  34039. getTransformNodesByID(id: string): Array<TransformNode>;
  34040. /**
  34041. * Gets a mesh with its auto-generated unique id
  34042. * @param uniqueId defines the unique id to search for
  34043. * @return the found mesh or null if not found at all.
  34044. */
  34045. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34046. /**
  34047. * Gets a the last added mesh using a given id
  34048. * @param id defines the id to search for
  34049. * @return the found mesh or null if not found at all.
  34050. */
  34051. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34052. /**
  34053. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34054. * @param id defines the id to search for
  34055. * @return the found node or null if not found at all
  34056. */
  34057. getLastEntryByID(id: string): Nullable<Node>;
  34058. /**
  34059. * Gets a node (Mesh, Camera, Light) using a given id
  34060. * @param id defines the id to search for
  34061. * @return the found node or null if not found at all
  34062. */
  34063. getNodeByID(id: string): Nullable<Node>;
  34064. /**
  34065. * Gets a node (Mesh, Camera, Light) using a given name
  34066. * @param name defines the name to search for
  34067. * @return the found node or null if not found at all.
  34068. */
  34069. getNodeByName(name: string): Nullable<Node>;
  34070. /**
  34071. * Gets a mesh using a given name
  34072. * @param name defines the name to search for
  34073. * @return the found mesh or null if not found at all.
  34074. */
  34075. getMeshByName(name: string): Nullable<AbstractMesh>;
  34076. /**
  34077. * Gets a transform node using a given name
  34078. * @param name defines the name to search for
  34079. * @return the found transform node or null if not found at all.
  34080. */
  34081. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34082. /**
  34083. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34084. * @param id defines the id to search for
  34085. * @return the found skeleton or null if not found at all.
  34086. */
  34087. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34088. /**
  34089. * Gets a skeleton using a given auto generated unique id
  34090. * @param uniqueId defines the unique id to search for
  34091. * @return the found skeleton or null if not found at all.
  34092. */
  34093. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34094. /**
  34095. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34096. * @param id defines the id to search for
  34097. * @return the found skeleton or null if not found at all.
  34098. */
  34099. getSkeletonById(id: string): Nullable<Skeleton>;
  34100. /**
  34101. * Gets a skeleton using a given name
  34102. * @param name defines the name to search for
  34103. * @return the found skeleton or null if not found at all.
  34104. */
  34105. getSkeletonByName(name: string): Nullable<Skeleton>;
  34106. /**
  34107. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34108. * @param id defines the id to search for
  34109. * @return the found morph target manager or null if not found at all.
  34110. */
  34111. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34112. /**
  34113. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34114. * @param id defines the id to search for
  34115. * @return the found morph target or null if not found at all.
  34116. */
  34117. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34118. /**
  34119. * Gets a boolean indicating if the given mesh is active
  34120. * @param mesh defines the mesh to look for
  34121. * @returns true if the mesh is in the active list
  34122. */
  34123. isActiveMesh(mesh: AbstractMesh): boolean;
  34124. /**
  34125. * Return a unique id as a string which can serve as an identifier for the scene
  34126. */
  34127. readonly uid: string;
  34128. /**
  34129. * Add an externaly attached data from its key.
  34130. * This method call will fail and return false, if such key already exists.
  34131. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34132. * @param key the unique key that identifies the data
  34133. * @param data the data object to associate to the key for this Engine instance
  34134. * @return true if no such key were already present and the data was added successfully, false otherwise
  34135. */
  34136. addExternalData<T>(key: string, data: T): boolean;
  34137. /**
  34138. * Get an externaly attached data from its key
  34139. * @param key the unique key that identifies the data
  34140. * @return the associated data, if present (can be null), or undefined if not present
  34141. */
  34142. getExternalData<T>(key: string): Nullable<T>;
  34143. /**
  34144. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34145. * @param key the unique key that identifies the data
  34146. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34147. * @return the associated data, can be null if the factory returned null.
  34148. */
  34149. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34150. /**
  34151. * Remove an externaly attached data from the Engine instance
  34152. * @param key the unique key that identifies the data
  34153. * @return true if the data was successfully removed, false if it doesn't exist
  34154. */
  34155. removeExternalData(key: string): boolean;
  34156. private _evaluateSubMesh;
  34157. /**
  34158. * Clear the processed materials smart array preventing retention point in material dispose.
  34159. */
  34160. freeProcessedMaterials(): void;
  34161. private _preventFreeActiveMeshesAndRenderingGroups;
  34162. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34163. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34164. * when disposing several meshes in a row or a hierarchy of meshes.
  34165. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34166. */
  34167. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34168. /**
  34169. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34170. */
  34171. freeActiveMeshes(): void;
  34172. /**
  34173. * Clear the info related to rendering groups preventing retention points during dispose.
  34174. */
  34175. freeRenderingGroups(): void;
  34176. /** @hidden */
  34177. _isInIntermediateRendering(): boolean;
  34178. /**
  34179. * Lambda returning the list of potentially active meshes.
  34180. */
  34181. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34182. /**
  34183. * Lambda returning the list of potentially active sub meshes.
  34184. */
  34185. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34186. /**
  34187. * Lambda returning the list of potentially intersecting sub meshes.
  34188. */
  34189. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34190. /**
  34191. * Lambda returning the list of potentially colliding sub meshes.
  34192. */
  34193. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34194. private _activeMeshesFrozen;
  34195. /**
  34196. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34197. * @returns the current scene
  34198. */
  34199. freezeActiveMeshes(): Scene;
  34200. /**
  34201. * Use this function to restart evaluating active meshes on every frame
  34202. * @returns the current scene
  34203. */
  34204. unfreezeActiveMeshes(): Scene;
  34205. private _evaluateActiveMeshes;
  34206. private _activeMesh;
  34207. /**
  34208. * Update the transform matrix to update from the current active camera
  34209. * @param force defines a boolean used to force the update even if cache is up to date
  34210. */
  34211. updateTransformMatrix(force?: boolean): void;
  34212. private _bindFrameBuffer;
  34213. /** @hidden */
  34214. _allowPostProcessClearColor: boolean;
  34215. /** @hidden */
  34216. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34217. private _processSubCameras;
  34218. private _checkIntersections;
  34219. /** @hidden */
  34220. _advancePhysicsEngineStep(step: number): void;
  34221. /**
  34222. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34223. */
  34224. getDeterministicFrameTime: () => number;
  34225. /** @hidden */
  34226. _animate(): void;
  34227. /** Execute all animations (for a frame) */
  34228. animate(): void;
  34229. /**
  34230. * Render the scene
  34231. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34232. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34233. */
  34234. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34235. /**
  34236. * Freeze all materials
  34237. * A frozen material will not be updatable but should be faster to render
  34238. */
  34239. freezeMaterials(): void;
  34240. /**
  34241. * Unfreeze all materials
  34242. * A frozen material will not be updatable but should be faster to render
  34243. */
  34244. unfreezeMaterials(): void;
  34245. /**
  34246. * Releases all held ressources
  34247. */
  34248. dispose(): void;
  34249. /**
  34250. * Gets if the scene is already disposed
  34251. */
  34252. readonly isDisposed: boolean;
  34253. /**
  34254. * Call this function to reduce memory footprint of the scene.
  34255. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34256. */
  34257. clearCachedVertexData(): void;
  34258. /**
  34259. * This function will remove the local cached buffer data from texture.
  34260. * It will save memory but will prevent the texture from being rebuilt
  34261. */
  34262. cleanCachedTextureBuffer(): void;
  34263. /**
  34264. * Get the world extend vectors with an optional filter
  34265. *
  34266. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34267. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34268. */
  34269. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34270. min: Vector3;
  34271. max: Vector3;
  34272. };
  34273. /**
  34274. * Creates a ray that can be used to pick in the scene
  34275. * @param x defines the x coordinate of the origin (on-screen)
  34276. * @param y defines the y coordinate of the origin (on-screen)
  34277. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34278. * @param camera defines the camera to use for the picking
  34279. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34280. * @returns a Ray
  34281. */
  34282. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34283. /**
  34284. * Creates a ray that can be used to pick in the scene
  34285. * @param x defines the x coordinate of the origin (on-screen)
  34286. * @param y defines the y coordinate of the origin (on-screen)
  34287. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34288. * @param result defines the ray where to store the picking ray
  34289. * @param camera defines the camera to use for the picking
  34290. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34291. * @returns the current scene
  34292. */
  34293. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34294. /**
  34295. * Creates a ray that can be used to pick in the scene
  34296. * @param x defines the x coordinate of the origin (on-screen)
  34297. * @param y defines the y coordinate of the origin (on-screen)
  34298. * @param camera defines the camera to use for the picking
  34299. * @returns a Ray
  34300. */
  34301. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34302. /**
  34303. * Creates a ray that can be used to pick in the scene
  34304. * @param x defines the x coordinate of the origin (on-screen)
  34305. * @param y defines the y coordinate of the origin (on-screen)
  34306. * @param result defines the ray where to store the picking ray
  34307. * @param camera defines the camera to use for the picking
  34308. * @returns the current scene
  34309. */
  34310. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34311. /** Launch a ray to try to pick a mesh in the scene
  34312. * @param x position on screen
  34313. * @param y position on screen
  34314. * @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
  34315. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34316. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34317. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34318. * @returns a PickingInfo
  34319. */
  34320. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34321. /** Use the given ray to pick a mesh in the scene
  34322. * @param ray The ray to use to pick meshes
  34323. * @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
  34324. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34326. * @returns a PickingInfo
  34327. */
  34328. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34329. /**
  34330. * Launch a ray to try to pick a mesh in the scene
  34331. * @param x X position on screen
  34332. * @param y Y position on screen
  34333. * @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
  34334. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34335. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34336. * @returns an array of PickingInfo
  34337. */
  34338. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34339. /**
  34340. * Launch a ray to try to pick a mesh in the scene
  34341. * @param ray Ray to use
  34342. * @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
  34343. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34344. * @returns an array of PickingInfo
  34345. */
  34346. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34347. /**
  34348. * Force the value of meshUnderPointer
  34349. * @param mesh defines the mesh to use
  34350. */
  34351. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34352. /**
  34353. * Gets the mesh under the pointer
  34354. * @returns a Mesh or null if no mesh is under the pointer
  34355. */
  34356. getPointerOverMesh(): Nullable<AbstractMesh>;
  34357. /** @hidden */
  34358. _rebuildGeometries(): void;
  34359. /** @hidden */
  34360. _rebuildTextures(): void;
  34361. private _getByTags;
  34362. /**
  34363. * Get a list of meshes by tags
  34364. * @param tagsQuery defines the tags query to use
  34365. * @param forEach defines a predicate used to filter results
  34366. * @returns an array of Mesh
  34367. */
  34368. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34369. /**
  34370. * Get a list of cameras by tags
  34371. * @param tagsQuery defines the tags query to use
  34372. * @param forEach defines a predicate used to filter results
  34373. * @returns an array of Camera
  34374. */
  34375. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34376. /**
  34377. * Get a list of lights by tags
  34378. * @param tagsQuery defines the tags query to use
  34379. * @param forEach defines a predicate used to filter results
  34380. * @returns an array of Light
  34381. */
  34382. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34383. /**
  34384. * Get a list of materials by tags
  34385. * @param tagsQuery defines the tags query to use
  34386. * @param forEach defines a predicate used to filter results
  34387. * @returns an array of Material
  34388. */
  34389. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34390. /**
  34391. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34392. * This allowed control for front to back rendering or reversly depending of the special needs.
  34393. *
  34394. * @param renderingGroupId The rendering group id corresponding to its index
  34395. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34396. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34397. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34398. */
  34399. 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;
  34400. /**
  34401. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34402. *
  34403. * @param renderingGroupId The rendering group id corresponding to its index
  34404. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34405. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34406. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34407. */
  34408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34409. /**
  34410. * Gets the current auto clear configuration for one rendering group of the rendering
  34411. * manager.
  34412. * @param index the rendering group index to get the information for
  34413. * @returns The auto clear setup for the requested rendering group
  34414. */
  34415. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34416. private _blockMaterialDirtyMechanism;
  34417. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34418. blockMaterialDirtyMechanism: boolean;
  34419. /**
  34420. * Will flag all materials as dirty to trigger new shader compilation
  34421. * @param flag defines the flag used to specify which material part must be marked as dirty
  34422. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34423. */
  34424. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34425. /** @hidden */
  34426. _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;
  34427. /** @hidden */
  34428. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34429. }
  34430. }
  34431. declare module BABYLON {
  34432. /**
  34433. * Set of assets to keep when moving a scene into an asset container.
  34434. */
  34435. export class KeepAssets extends AbstractScene {
  34436. }
  34437. /**
  34438. * Container with a set of assets that can be added or removed from a scene.
  34439. */
  34440. export class AssetContainer extends AbstractScene {
  34441. /**
  34442. * The scene the AssetContainer belongs to.
  34443. */
  34444. scene: Scene;
  34445. /**
  34446. * Instantiates an AssetContainer.
  34447. * @param scene The scene the AssetContainer belongs to.
  34448. */
  34449. constructor(scene: Scene);
  34450. /**
  34451. * Adds all the assets from the container to the scene.
  34452. */
  34453. addAllToScene(): void;
  34454. /**
  34455. * Removes all the assets in the container from the scene
  34456. */
  34457. removeAllFromScene(): void;
  34458. /**
  34459. * Disposes all the assets in the container
  34460. */
  34461. dispose(): void;
  34462. private _moveAssets;
  34463. /**
  34464. * Removes all the assets contained in the scene and adds them to the container.
  34465. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34466. */
  34467. moveAllFromScene(keepAssets?: KeepAssets): void;
  34468. /**
  34469. * 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.
  34470. * @returns the root mesh
  34471. */
  34472. createRootMesh(): Mesh;
  34473. }
  34474. }
  34475. declare module BABYLON {
  34476. /**
  34477. * Defines how the parser contract is defined.
  34478. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34479. */
  34480. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34481. /**
  34482. * Defines how the individual parser contract is defined.
  34483. * These parser can parse an individual asset
  34484. */
  34485. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34486. /**
  34487. * Base class of the scene acting as a container for the different elements composing a scene.
  34488. * This class is dynamically extended by the different components of the scene increasing
  34489. * flexibility and reducing coupling
  34490. */
  34491. export abstract class AbstractScene {
  34492. /**
  34493. * Stores the list of available parsers in the application.
  34494. */
  34495. private static _BabylonFileParsers;
  34496. /**
  34497. * Stores the list of available individual parsers in the application.
  34498. */
  34499. private static _IndividualBabylonFileParsers;
  34500. /**
  34501. * Adds a parser in the list of available ones
  34502. * @param name Defines the name of the parser
  34503. * @param parser Defines the parser to add
  34504. */
  34505. static AddParser(name: string, parser: BabylonFileParser): void;
  34506. /**
  34507. * Gets a general parser from the list of avaialble ones
  34508. * @param name Defines the name of the parser
  34509. * @returns the requested parser or null
  34510. */
  34511. static GetParser(name: string): Nullable<BabylonFileParser>;
  34512. /**
  34513. * Adds n individual parser in the list of available ones
  34514. * @param name Defines the name of the parser
  34515. * @param parser Defines the parser to add
  34516. */
  34517. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34518. /**
  34519. * Gets an individual parser from the list of avaialble ones
  34520. * @param name Defines the name of the parser
  34521. * @returns the requested parser or null
  34522. */
  34523. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34524. /**
  34525. * Parser json data and populate both a scene and its associated container object
  34526. * @param jsonData Defines the data to parse
  34527. * @param scene Defines the scene to parse the data for
  34528. * @param container Defines the container attached to the parsing sequence
  34529. * @param rootUrl Defines the root url of the data
  34530. */
  34531. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34532. /**
  34533. * Gets the list of root nodes (ie. nodes with no parent)
  34534. */
  34535. rootNodes: Node[];
  34536. /** All of the cameras added to this scene
  34537. * @see http://doc.babylonjs.com/babylon101/cameras
  34538. */
  34539. cameras: Camera[];
  34540. /**
  34541. * All of the lights added to this scene
  34542. * @see http://doc.babylonjs.com/babylon101/lights
  34543. */
  34544. lights: Light[];
  34545. /**
  34546. * All of the (abstract) meshes added to this scene
  34547. */
  34548. meshes: AbstractMesh[];
  34549. /**
  34550. * The list of skeletons added to the scene
  34551. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34552. */
  34553. skeletons: Skeleton[];
  34554. /**
  34555. * All of the particle systems added to this scene
  34556. * @see http://doc.babylonjs.com/babylon101/particles
  34557. */
  34558. particleSystems: IParticleSystem[];
  34559. /**
  34560. * Gets a list of Animations associated with the scene
  34561. */
  34562. animations: Animation[];
  34563. /**
  34564. * All of the animation groups added to this scene
  34565. * @see http://doc.babylonjs.com/how_to/group
  34566. */
  34567. animationGroups: AnimationGroup[];
  34568. /**
  34569. * All of the multi-materials added to this scene
  34570. * @see http://doc.babylonjs.com/how_to/multi_materials
  34571. */
  34572. multiMaterials: MultiMaterial[];
  34573. /**
  34574. * All of the materials added to this scene
  34575. * In the context of a Scene, it is not supposed to be modified manually.
  34576. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34577. * Note also that the order of the Material wihin the array is not significant and might change.
  34578. * @see http://doc.babylonjs.com/babylon101/materials
  34579. */
  34580. materials: Material[];
  34581. /**
  34582. * The list of morph target managers added to the scene
  34583. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34584. */
  34585. morphTargetManagers: MorphTargetManager[];
  34586. /**
  34587. * The list of geometries used in the scene.
  34588. */
  34589. geometries: Geometry[];
  34590. /**
  34591. * All of the tranform nodes added to this scene
  34592. * In the context of a Scene, it is not supposed to be modified manually.
  34593. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34594. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34595. * @see http://doc.babylonjs.com/how_to/transformnode
  34596. */
  34597. transformNodes: TransformNode[];
  34598. /**
  34599. * ActionManagers available on the scene.
  34600. */
  34601. actionManagers: AbstractActionManager[];
  34602. /**
  34603. * Textures to keep.
  34604. */
  34605. textures: BaseTexture[];
  34606. /**
  34607. * Environment texture for the scene
  34608. */
  34609. environmentTexture: Nullable<BaseTexture>;
  34610. }
  34611. }
  34612. declare module BABYLON {
  34613. /**
  34614. * Interface used to define options for Sound class
  34615. */
  34616. export interface ISoundOptions {
  34617. /**
  34618. * Does the sound autoplay once loaded.
  34619. */
  34620. autoplay?: boolean;
  34621. /**
  34622. * Does the sound loop after it finishes playing once.
  34623. */
  34624. loop?: boolean;
  34625. /**
  34626. * Sound's volume
  34627. */
  34628. volume?: number;
  34629. /**
  34630. * Is it a spatial sound?
  34631. */
  34632. spatialSound?: boolean;
  34633. /**
  34634. * Maximum distance to hear that sound
  34635. */
  34636. maxDistance?: number;
  34637. /**
  34638. * Uses user defined attenuation function
  34639. */
  34640. useCustomAttenuation?: boolean;
  34641. /**
  34642. * Define the roll off factor of spatial sounds.
  34643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34644. */
  34645. rolloffFactor?: number;
  34646. /**
  34647. * Define the reference distance the sound should be heard perfectly.
  34648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34649. */
  34650. refDistance?: number;
  34651. /**
  34652. * Define the distance attenuation model the sound will follow.
  34653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34654. */
  34655. distanceModel?: string;
  34656. /**
  34657. * Defines the playback speed (1 by default)
  34658. */
  34659. playbackRate?: number;
  34660. /**
  34661. * Defines if the sound is from a streaming source
  34662. */
  34663. streaming?: boolean;
  34664. /**
  34665. * Defines an optional length (in seconds) inside the sound file
  34666. */
  34667. length?: number;
  34668. /**
  34669. * Defines an optional offset (in seconds) inside the sound file
  34670. */
  34671. offset?: number;
  34672. /**
  34673. * If true, URLs will not be required to state the audio file codec to use.
  34674. */
  34675. skipCodecCheck?: boolean;
  34676. }
  34677. /**
  34678. * Defines a sound that can be played in the application.
  34679. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34681. */
  34682. export class Sound {
  34683. /**
  34684. * The name of the sound in the scene.
  34685. */
  34686. name: string;
  34687. /**
  34688. * Does the sound autoplay once loaded.
  34689. */
  34690. autoplay: boolean;
  34691. /**
  34692. * Does the sound loop after it finishes playing once.
  34693. */
  34694. loop: boolean;
  34695. /**
  34696. * Does the sound use a custom attenuation curve to simulate the falloff
  34697. * happening when the source gets further away from the camera.
  34698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34699. */
  34700. useCustomAttenuation: boolean;
  34701. /**
  34702. * The sound track id this sound belongs to.
  34703. */
  34704. soundTrackId: number;
  34705. /**
  34706. * Is this sound currently played.
  34707. */
  34708. isPlaying: boolean;
  34709. /**
  34710. * Is this sound currently paused.
  34711. */
  34712. isPaused: boolean;
  34713. /**
  34714. * Does this sound enables spatial sound.
  34715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34716. */
  34717. spatialSound: boolean;
  34718. /**
  34719. * Define the reference distance the sound should be heard perfectly.
  34720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34721. */
  34722. refDistance: number;
  34723. /**
  34724. * Define the roll off factor of spatial sounds.
  34725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34726. */
  34727. rolloffFactor: number;
  34728. /**
  34729. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34731. */
  34732. maxDistance: number;
  34733. /**
  34734. * Define the distance attenuation model the sound will follow.
  34735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34736. */
  34737. distanceModel: string;
  34738. /**
  34739. * @hidden
  34740. * Back Compat
  34741. **/
  34742. onended: () => any;
  34743. /**
  34744. * Observable event when the current playing sound finishes.
  34745. */
  34746. onEndedObservable: Observable<Sound>;
  34747. private _panningModel;
  34748. private _playbackRate;
  34749. private _streaming;
  34750. private _startTime;
  34751. private _startOffset;
  34752. private _position;
  34753. /** @hidden */
  34754. _positionInEmitterSpace: boolean;
  34755. private _localDirection;
  34756. private _volume;
  34757. private _isReadyToPlay;
  34758. private _isDirectional;
  34759. private _readyToPlayCallback;
  34760. private _audioBuffer;
  34761. private _soundSource;
  34762. private _streamingSource;
  34763. private _soundPanner;
  34764. private _soundGain;
  34765. private _inputAudioNode;
  34766. private _outputAudioNode;
  34767. private _coneInnerAngle;
  34768. private _coneOuterAngle;
  34769. private _coneOuterGain;
  34770. private _scene;
  34771. private _connectedTransformNode;
  34772. private _customAttenuationFunction;
  34773. private _registerFunc;
  34774. private _isOutputConnected;
  34775. private _htmlAudioElement;
  34776. private _urlType;
  34777. private _length?;
  34778. private _offset?;
  34779. /** @hidden */
  34780. static _SceneComponentInitialization: (scene: Scene) => void;
  34781. /**
  34782. * Create a sound and attach it to a scene
  34783. * @param name Name of your sound
  34784. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34785. * @param scene defines the scene the sound belongs to
  34786. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34787. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34788. */
  34789. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34790. /**
  34791. * Release the sound and its associated resources
  34792. */
  34793. dispose(): void;
  34794. /**
  34795. * Gets if the sounds is ready to be played or not.
  34796. * @returns true if ready, otherwise false
  34797. */
  34798. isReady(): boolean;
  34799. private _soundLoaded;
  34800. /**
  34801. * Sets the data of the sound from an audiobuffer
  34802. * @param audioBuffer The audioBuffer containing the data
  34803. */
  34804. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34805. /**
  34806. * Updates the current sounds options such as maxdistance, loop...
  34807. * @param options A JSON object containing values named as the object properties
  34808. */
  34809. updateOptions(options: ISoundOptions): void;
  34810. private _createSpatialParameters;
  34811. private _updateSpatialParameters;
  34812. /**
  34813. * Switch the panning model to HRTF:
  34814. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34816. */
  34817. switchPanningModelToHRTF(): void;
  34818. /**
  34819. * Switch the panning model to Equal Power:
  34820. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34822. */
  34823. switchPanningModelToEqualPower(): void;
  34824. private _switchPanningModel;
  34825. /**
  34826. * Connect this sound to a sound track audio node like gain...
  34827. * @param soundTrackAudioNode the sound track audio node to connect to
  34828. */
  34829. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34830. /**
  34831. * Transform this sound into a directional source
  34832. * @param coneInnerAngle Size of the inner cone in degree
  34833. * @param coneOuterAngle Size of the outer cone in degree
  34834. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34835. */
  34836. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34837. /**
  34838. * Gets or sets the inner angle for the directional cone.
  34839. */
  34840. /**
  34841. * Gets or sets the inner angle for the directional cone.
  34842. */
  34843. directionalConeInnerAngle: number;
  34844. /**
  34845. * Gets or sets the outer angle for the directional cone.
  34846. */
  34847. /**
  34848. * Gets or sets the outer angle for the directional cone.
  34849. */
  34850. directionalConeOuterAngle: number;
  34851. /**
  34852. * Sets the position of the emitter if spatial sound is enabled
  34853. * @param newPosition Defines the new posisiton
  34854. */
  34855. setPosition(newPosition: Vector3): void;
  34856. /**
  34857. * Sets the local direction of the emitter if spatial sound is enabled
  34858. * @param newLocalDirection Defines the new local direction
  34859. */
  34860. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34861. private _updateDirection;
  34862. /** @hidden */
  34863. updateDistanceFromListener(): void;
  34864. /**
  34865. * Sets a new custom attenuation function for the sound.
  34866. * @param callback Defines the function used for the attenuation
  34867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34868. */
  34869. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34870. /**
  34871. * Play the sound
  34872. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34873. * @param offset (optional) Start the sound at a specific time in seconds
  34874. * @param length (optional) Sound duration (in seconds)
  34875. */
  34876. play(time?: number, offset?: number, length?: number): void;
  34877. private _onended;
  34878. /**
  34879. * Stop the sound
  34880. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34881. */
  34882. stop(time?: number): void;
  34883. /**
  34884. * Put the sound in pause
  34885. */
  34886. pause(): void;
  34887. /**
  34888. * Sets a dedicated volume for this sounds
  34889. * @param newVolume Define the new volume of the sound
  34890. * @param time Define time for gradual change to new volume
  34891. */
  34892. setVolume(newVolume: number, time?: number): void;
  34893. /**
  34894. * Set the sound play back rate
  34895. * @param newPlaybackRate Define the playback rate the sound should be played at
  34896. */
  34897. setPlaybackRate(newPlaybackRate: number): void;
  34898. /**
  34899. * Gets the volume of the sound.
  34900. * @returns the volume of the sound
  34901. */
  34902. getVolume(): number;
  34903. /**
  34904. * Attach the sound to a dedicated mesh
  34905. * @param transformNode The transform node to connect the sound with
  34906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34907. */
  34908. attachToMesh(transformNode: TransformNode): void;
  34909. /**
  34910. * Detach the sound from the previously attached mesh
  34911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34912. */
  34913. detachFromMesh(): void;
  34914. private _onRegisterAfterWorldMatrixUpdate;
  34915. /**
  34916. * Clone the current sound in the scene.
  34917. * @returns the new sound clone
  34918. */
  34919. clone(): Nullable<Sound>;
  34920. /**
  34921. * Gets the current underlying audio buffer containing the data
  34922. * @returns the audio buffer
  34923. */
  34924. getAudioBuffer(): Nullable<AudioBuffer>;
  34925. /**
  34926. * Serializes the Sound in a JSON representation
  34927. * @returns the JSON representation of the sound
  34928. */
  34929. serialize(): any;
  34930. /**
  34931. * Parse a JSON representation of a sound to innstantiate in a given scene
  34932. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34933. * @param scene Define the scene the new parsed sound should be created in
  34934. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34935. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34936. * @returns the newly parsed sound
  34937. */
  34938. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34939. }
  34940. }
  34941. declare module BABYLON {
  34942. /**
  34943. * This defines an action helpful to play a defined sound on a triggered action.
  34944. */
  34945. export class PlaySoundAction extends Action {
  34946. private _sound;
  34947. /**
  34948. * Instantiate the action
  34949. * @param triggerOptions defines the trigger options
  34950. * @param sound defines the sound to play
  34951. * @param condition defines the trigger related conditions
  34952. */
  34953. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34954. /** @hidden */
  34955. _prepare(): void;
  34956. /**
  34957. * Execute the action and play the sound.
  34958. */
  34959. execute(): void;
  34960. /**
  34961. * Serializes the actions and its related information.
  34962. * @param parent defines the object to serialize in
  34963. * @returns the serialized object
  34964. */
  34965. serialize(parent: any): any;
  34966. }
  34967. /**
  34968. * This defines an action helpful to stop a defined sound on a triggered action.
  34969. */
  34970. export class StopSoundAction extends Action {
  34971. private _sound;
  34972. /**
  34973. * Instantiate the action
  34974. * @param triggerOptions defines the trigger options
  34975. * @param sound defines the sound to stop
  34976. * @param condition defines the trigger related conditions
  34977. */
  34978. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34979. /** @hidden */
  34980. _prepare(): void;
  34981. /**
  34982. * Execute the action and stop the sound.
  34983. */
  34984. execute(): void;
  34985. /**
  34986. * Serializes the actions and its related information.
  34987. * @param parent defines the object to serialize in
  34988. * @returns the serialized object
  34989. */
  34990. serialize(parent: any): any;
  34991. }
  34992. }
  34993. declare module BABYLON {
  34994. /**
  34995. * This defines an action responsible to change the value of a property
  34996. * by interpolating between its current value and the newly set one once triggered.
  34997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34998. */
  34999. export class InterpolateValueAction extends Action {
  35000. /**
  35001. * Defines the path of the property where the value should be interpolated
  35002. */
  35003. propertyPath: string;
  35004. /**
  35005. * Defines the target value at the end of the interpolation.
  35006. */
  35007. value: any;
  35008. /**
  35009. * Defines the time it will take for the property to interpolate to the value.
  35010. */
  35011. duration: number;
  35012. /**
  35013. * Defines if the other scene animations should be stopped when the action has been triggered
  35014. */
  35015. stopOtherAnimations?: boolean;
  35016. /**
  35017. * Defines a callback raised once the interpolation animation has been done.
  35018. */
  35019. onInterpolationDone?: () => void;
  35020. /**
  35021. * Observable triggered once the interpolation animation has been done.
  35022. */
  35023. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35024. private _target;
  35025. private _effectiveTarget;
  35026. private _property;
  35027. /**
  35028. * Instantiate the action
  35029. * @param triggerOptions defines the trigger options
  35030. * @param target defines the object containing the value to interpolate
  35031. * @param propertyPath defines the path to the property in the target object
  35032. * @param value defines the target value at the end of the interpolation
  35033. * @param duration deines the time it will take for the property to interpolate to the value.
  35034. * @param condition defines the trigger related conditions
  35035. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35036. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35037. */
  35038. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35039. /** @hidden */
  35040. _prepare(): void;
  35041. /**
  35042. * Execute the action starts the value interpolation.
  35043. */
  35044. execute(): void;
  35045. /**
  35046. * Serializes the actions and its related information.
  35047. * @param parent defines the object to serialize in
  35048. * @returns the serialized object
  35049. */
  35050. serialize(parent: any): any;
  35051. }
  35052. }
  35053. declare module BABYLON {
  35054. /**
  35055. * Options allowed during the creation of a sound track.
  35056. */
  35057. export interface ISoundTrackOptions {
  35058. /**
  35059. * The volume the sound track should take during creation
  35060. */
  35061. volume?: number;
  35062. /**
  35063. * Define if the sound track is the main sound track of the scene
  35064. */
  35065. mainTrack?: boolean;
  35066. }
  35067. /**
  35068. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35069. * It will be also used in a future release to apply effects on a specific track.
  35070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35071. */
  35072. export class SoundTrack {
  35073. /**
  35074. * The unique identifier of the sound track in the scene.
  35075. */
  35076. id: number;
  35077. /**
  35078. * The list of sounds included in the sound track.
  35079. */
  35080. soundCollection: Array<Sound>;
  35081. private _outputAudioNode;
  35082. private _scene;
  35083. private _isMainTrack;
  35084. private _connectedAnalyser;
  35085. private _options;
  35086. private _isInitialized;
  35087. /**
  35088. * Creates a new sound track.
  35089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35090. * @param scene Define the scene the sound track belongs to
  35091. * @param options
  35092. */
  35093. constructor(scene: Scene, options?: ISoundTrackOptions);
  35094. private _initializeSoundTrackAudioGraph;
  35095. /**
  35096. * Release the sound track and its associated resources
  35097. */
  35098. dispose(): void;
  35099. /**
  35100. * Adds a sound to this sound track
  35101. * @param sound define the cound to add
  35102. * @ignoreNaming
  35103. */
  35104. AddSound(sound: Sound): void;
  35105. /**
  35106. * Removes a sound to this sound track
  35107. * @param sound define the cound to remove
  35108. * @ignoreNaming
  35109. */
  35110. RemoveSound(sound: Sound): void;
  35111. /**
  35112. * Set a global volume for the full sound track.
  35113. * @param newVolume Define the new volume of the sound track
  35114. */
  35115. setVolume(newVolume: number): void;
  35116. /**
  35117. * Switch the panning model to HRTF:
  35118. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35120. */
  35121. switchPanningModelToHRTF(): void;
  35122. /**
  35123. * Switch the panning model to Equal Power:
  35124. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35126. */
  35127. switchPanningModelToEqualPower(): void;
  35128. /**
  35129. * Connect the sound track to an audio analyser allowing some amazing
  35130. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35132. * @param analyser The analyser to connect to the engine
  35133. */
  35134. connectToAnalyser(analyser: Analyser): void;
  35135. }
  35136. }
  35137. declare module BABYLON {
  35138. interface AbstractScene {
  35139. /**
  35140. * The list of sounds used in the scene.
  35141. */
  35142. sounds: Nullable<Array<Sound>>;
  35143. }
  35144. interface Scene {
  35145. /**
  35146. * @hidden
  35147. * Backing field
  35148. */
  35149. _mainSoundTrack: SoundTrack;
  35150. /**
  35151. * The main sound track played by the scene.
  35152. * It cotains your primary collection of sounds.
  35153. */
  35154. mainSoundTrack: SoundTrack;
  35155. /**
  35156. * The list of sound tracks added to the scene
  35157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35158. */
  35159. soundTracks: Nullable<Array<SoundTrack>>;
  35160. /**
  35161. * Gets a sound using a given name
  35162. * @param name defines the name to search for
  35163. * @return the found sound or null if not found at all.
  35164. */
  35165. getSoundByName(name: string): Nullable<Sound>;
  35166. /**
  35167. * Gets or sets if audio support is enabled
  35168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35169. */
  35170. audioEnabled: boolean;
  35171. /**
  35172. * Gets or sets if audio will be output to headphones
  35173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35174. */
  35175. headphone: boolean;
  35176. }
  35177. /**
  35178. * Defines the sound scene component responsible to manage any sounds
  35179. * in a given scene.
  35180. */
  35181. export class AudioSceneComponent implements ISceneSerializableComponent {
  35182. /**
  35183. * The component name helpfull to identify the component in the list of scene components.
  35184. */
  35185. readonly name: string;
  35186. /**
  35187. * The scene the component belongs to.
  35188. */
  35189. scene: Scene;
  35190. private _audioEnabled;
  35191. /**
  35192. * Gets whether audio is enabled or not.
  35193. * Please use related enable/disable method to switch state.
  35194. */
  35195. readonly audioEnabled: boolean;
  35196. private _headphone;
  35197. /**
  35198. * Gets whether audio is outputing to headphone or not.
  35199. * Please use the according Switch methods to change output.
  35200. */
  35201. readonly headphone: boolean;
  35202. /**
  35203. * Creates a new instance of the component for the given scene
  35204. * @param scene Defines the scene to register the component in
  35205. */
  35206. constructor(scene: Scene);
  35207. /**
  35208. * Registers the component in a given scene
  35209. */
  35210. register(): void;
  35211. /**
  35212. * Rebuilds the elements related to this component in case of
  35213. * context lost for instance.
  35214. */
  35215. rebuild(): void;
  35216. /**
  35217. * Serializes the component data to the specified json object
  35218. * @param serializationObject The object to serialize to
  35219. */
  35220. serialize(serializationObject: any): void;
  35221. /**
  35222. * Adds all the elements from the container to the scene
  35223. * @param container the container holding the elements
  35224. */
  35225. addFromContainer(container: AbstractScene): void;
  35226. /**
  35227. * Removes all the elements in the container from the scene
  35228. * @param container contains the elements to remove
  35229. * @param dispose if the removed element should be disposed (default: false)
  35230. */
  35231. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35232. /**
  35233. * Disposes the component and the associated ressources.
  35234. */
  35235. dispose(): void;
  35236. /**
  35237. * Disables audio in the associated scene.
  35238. */
  35239. disableAudio(): void;
  35240. /**
  35241. * Enables audio in the associated scene.
  35242. */
  35243. enableAudio(): void;
  35244. /**
  35245. * Switch audio to headphone output.
  35246. */
  35247. switchAudioModeForHeadphones(): void;
  35248. /**
  35249. * Switch audio to normal speakers.
  35250. */
  35251. switchAudioModeForNormalSpeakers(): void;
  35252. private _afterRender;
  35253. }
  35254. }
  35255. declare module BABYLON {
  35256. /**
  35257. * Wraps one or more Sound objects and selects one with random weight for playback.
  35258. */
  35259. export class WeightedSound {
  35260. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35261. loop: boolean;
  35262. private _coneInnerAngle;
  35263. private _coneOuterAngle;
  35264. private _volume;
  35265. /** A Sound is currently playing. */
  35266. isPlaying: boolean;
  35267. /** A Sound is currently paused. */
  35268. isPaused: boolean;
  35269. private _sounds;
  35270. private _weights;
  35271. private _currentIndex?;
  35272. /**
  35273. * Creates a new WeightedSound from the list of sounds given.
  35274. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35275. * @param sounds Array of Sounds that will be selected from.
  35276. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35277. */
  35278. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35279. /**
  35280. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35281. */
  35282. /**
  35283. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35284. */
  35285. directionalConeInnerAngle: number;
  35286. /**
  35287. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35288. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35289. */
  35290. /**
  35291. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35292. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35293. */
  35294. directionalConeOuterAngle: number;
  35295. /**
  35296. * Playback volume.
  35297. */
  35298. /**
  35299. * Playback volume.
  35300. */
  35301. volume: number;
  35302. private _onended;
  35303. /**
  35304. * Suspend playback
  35305. */
  35306. pause(): void;
  35307. /**
  35308. * Stop playback
  35309. */
  35310. stop(): void;
  35311. /**
  35312. * Start playback.
  35313. * @param startOffset Position the clip head at a specific time in seconds.
  35314. */
  35315. play(startOffset?: number): void;
  35316. }
  35317. }
  35318. declare module BABYLON {
  35319. /**
  35320. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35322. */
  35323. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35324. /**
  35325. * Gets the name of the behavior.
  35326. */
  35327. readonly name: string;
  35328. /**
  35329. * The easing function used by animations
  35330. */
  35331. static EasingFunction: BackEase;
  35332. /**
  35333. * The easing mode used by animations
  35334. */
  35335. static EasingMode: number;
  35336. /**
  35337. * The duration of the animation, in milliseconds
  35338. */
  35339. transitionDuration: number;
  35340. /**
  35341. * Length of the distance animated by the transition when lower radius is reached
  35342. */
  35343. lowerRadiusTransitionRange: number;
  35344. /**
  35345. * Length of the distance animated by the transition when upper radius is reached
  35346. */
  35347. upperRadiusTransitionRange: number;
  35348. private _autoTransitionRange;
  35349. /**
  35350. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35351. */
  35352. /**
  35353. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35354. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35355. */
  35356. autoTransitionRange: boolean;
  35357. private _attachedCamera;
  35358. private _onAfterCheckInputsObserver;
  35359. private _onMeshTargetChangedObserver;
  35360. /**
  35361. * Initializes the behavior.
  35362. */
  35363. init(): void;
  35364. /**
  35365. * Attaches the behavior to its arc rotate camera.
  35366. * @param camera Defines the camera to attach the behavior to
  35367. */
  35368. attach(camera: ArcRotateCamera): void;
  35369. /**
  35370. * Detaches the behavior from its current arc rotate camera.
  35371. */
  35372. detach(): void;
  35373. private _radiusIsAnimating;
  35374. private _radiusBounceTransition;
  35375. private _animatables;
  35376. private _cachedWheelPrecision;
  35377. /**
  35378. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35379. * @param radiusLimit The limit to check against.
  35380. * @return Bool to indicate if at limit.
  35381. */
  35382. private _isRadiusAtLimit;
  35383. /**
  35384. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35385. * @param radiusDelta The delta by which to animate to. Can be negative.
  35386. */
  35387. private _applyBoundRadiusAnimation;
  35388. /**
  35389. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35390. */
  35391. protected _clearAnimationLocks(): void;
  35392. /**
  35393. * Stops and removes all animations that have been applied to the camera
  35394. */
  35395. stopAllAnimations(): void;
  35396. }
  35397. }
  35398. declare module BABYLON {
  35399. /**
  35400. * 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.
  35401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35402. */
  35403. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35404. /**
  35405. * Gets the name of the behavior.
  35406. */
  35407. readonly name: string;
  35408. private _mode;
  35409. private _radiusScale;
  35410. private _positionScale;
  35411. private _defaultElevation;
  35412. private _elevationReturnTime;
  35413. private _elevationReturnWaitTime;
  35414. private _zoomStopsAnimation;
  35415. private _framingTime;
  35416. /**
  35417. * The easing function used by animations
  35418. */
  35419. static EasingFunction: ExponentialEase;
  35420. /**
  35421. * The easing mode used by animations
  35422. */
  35423. static EasingMode: number;
  35424. /**
  35425. * Sets the current mode used by the behavior
  35426. */
  35427. /**
  35428. * Gets current mode used by the behavior.
  35429. */
  35430. mode: number;
  35431. /**
  35432. * Sets the scale applied to the radius (1 by default)
  35433. */
  35434. /**
  35435. * Gets the scale applied to the radius
  35436. */
  35437. radiusScale: number;
  35438. /**
  35439. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35440. */
  35441. /**
  35442. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35443. */
  35444. positionScale: number;
  35445. /**
  35446. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35447. * behaviour is triggered, in radians.
  35448. */
  35449. /**
  35450. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35451. * behaviour is triggered, in radians.
  35452. */
  35453. defaultElevation: number;
  35454. /**
  35455. * Sets the time (in milliseconds) taken to return to the default beta position.
  35456. * Negative value indicates camera should not return to default.
  35457. */
  35458. /**
  35459. * Gets the time (in milliseconds) taken to return to the default beta position.
  35460. * Negative value indicates camera should not return to default.
  35461. */
  35462. elevationReturnTime: number;
  35463. /**
  35464. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35465. */
  35466. /**
  35467. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35468. */
  35469. elevationReturnWaitTime: number;
  35470. /**
  35471. * Sets the flag that indicates if user zooming should stop animation.
  35472. */
  35473. /**
  35474. * Gets the flag that indicates if user zooming should stop animation.
  35475. */
  35476. zoomStopsAnimation: boolean;
  35477. /**
  35478. * Sets the transition time when framing the mesh, in milliseconds
  35479. */
  35480. /**
  35481. * Gets the transition time when framing the mesh, in milliseconds
  35482. */
  35483. framingTime: number;
  35484. /**
  35485. * Define if the behavior should automatically change the configured
  35486. * camera limits and sensibilities.
  35487. */
  35488. autoCorrectCameraLimitsAndSensibility: boolean;
  35489. private _onPrePointerObservableObserver;
  35490. private _onAfterCheckInputsObserver;
  35491. private _onMeshTargetChangedObserver;
  35492. private _attachedCamera;
  35493. private _isPointerDown;
  35494. private _lastInteractionTime;
  35495. /**
  35496. * Initializes the behavior.
  35497. */
  35498. init(): void;
  35499. /**
  35500. * Attaches the behavior to its arc rotate camera.
  35501. * @param camera Defines the camera to attach the behavior to
  35502. */
  35503. attach(camera: ArcRotateCamera): void;
  35504. /**
  35505. * Detaches the behavior from its current arc rotate camera.
  35506. */
  35507. detach(): void;
  35508. private _animatables;
  35509. private _betaIsAnimating;
  35510. private _betaTransition;
  35511. private _radiusTransition;
  35512. private _vectorTransition;
  35513. /**
  35514. * Targets the given mesh and updates zoom level accordingly.
  35515. * @param mesh The mesh to target.
  35516. * @param radius Optional. If a cached radius position already exists, overrides default.
  35517. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35518. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35519. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35520. */
  35521. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35522. /**
  35523. * Targets the given mesh with its children and updates zoom level accordingly.
  35524. * @param mesh The mesh to target.
  35525. * @param radius Optional. If a cached radius position already exists, overrides default.
  35526. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35527. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35528. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35529. */
  35530. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35531. /**
  35532. * Targets the given meshes with their children and updates zoom level accordingly.
  35533. * @param meshes The mesh to target.
  35534. * @param radius Optional. If a cached radius position already exists, overrides default.
  35535. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35538. */
  35539. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35540. /**
  35541. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35542. * @param minimumWorld Determines the smaller position of the bounding box extend
  35543. * @param maximumWorld Determines the bigger position of the bounding box extend
  35544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35546. */
  35547. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35548. /**
  35549. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35550. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35551. * frustum width.
  35552. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35553. * to fully enclose the mesh in the viewing frustum.
  35554. */
  35555. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35556. /**
  35557. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35558. * is automatically returned to its default position (expected to be above ground plane).
  35559. */
  35560. private _maintainCameraAboveGround;
  35561. /**
  35562. * Returns the frustum slope based on the canvas ratio and camera FOV
  35563. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35564. */
  35565. private _getFrustumSlope;
  35566. /**
  35567. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35568. */
  35569. private _clearAnimationLocks;
  35570. /**
  35571. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35572. */
  35573. private _applyUserInteraction;
  35574. /**
  35575. * Stops and removes all animations that have been applied to the camera
  35576. */
  35577. stopAllAnimations(): void;
  35578. /**
  35579. * Gets a value indicating if the user is moving the camera
  35580. */
  35581. readonly isUserIsMoving: boolean;
  35582. /**
  35583. * The camera can move all the way towards the mesh.
  35584. */
  35585. static IgnoreBoundsSizeMode: number;
  35586. /**
  35587. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35588. */
  35589. static FitFrustumSidesMode: number;
  35590. }
  35591. }
  35592. declare module BABYLON {
  35593. /**
  35594. * Base class for Camera Pointer Inputs.
  35595. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35596. * for example usage.
  35597. */
  35598. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35599. /**
  35600. * Defines the camera the input is attached to.
  35601. */
  35602. abstract camera: Camera;
  35603. /**
  35604. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35605. */
  35606. protected _altKey: boolean;
  35607. protected _ctrlKey: boolean;
  35608. protected _metaKey: boolean;
  35609. protected _shiftKey: boolean;
  35610. /**
  35611. * Which mouse buttons were pressed at time of last mouse event.
  35612. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35613. */
  35614. protected _buttonsPressed: number;
  35615. /**
  35616. * Defines the buttons associated with the input to handle camera move.
  35617. */
  35618. buttons: number[];
  35619. /**
  35620. * Attach the input controls to a specific dom element to get the input from.
  35621. * @param element Defines the element the controls should be listened from
  35622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35623. */
  35624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35625. /**
  35626. * Detach the current controls from the specified dom element.
  35627. * @param element Defines the element to stop listening the inputs from
  35628. */
  35629. detachControl(element: Nullable<HTMLElement>): void;
  35630. /**
  35631. * Gets the class name of the current input.
  35632. * @returns the class name
  35633. */
  35634. getClassName(): string;
  35635. /**
  35636. * Get the friendly name associated with the input class.
  35637. * @returns the input friendly name
  35638. */
  35639. getSimpleName(): string;
  35640. /**
  35641. * Called on pointer POINTERDOUBLETAP event.
  35642. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35643. */
  35644. protected onDoubleTap(type: string): void;
  35645. /**
  35646. * Called on pointer POINTERMOVE event if only a single touch is active.
  35647. * Override this method to provide functionality.
  35648. */
  35649. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35650. /**
  35651. * Called on pointer POINTERMOVE event if multiple touches are active.
  35652. * Override this method to provide functionality.
  35653. */
  35654. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35655. /**
  35656. * Called on JS contextmenu event.
  35657. * Override this method to provide functionality.
  35658. */
  35659. protected onContextMenu(evt: PointerEvent): void;
  35660. /**
  35661. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35662. * press.
  35663. * Override this method to provide functionality.
  35664. */
  35665. protected onButtonDown(evt: PointerEvent): void;
  35666. /**
  35667. * Called each time a new POINTERUP event occurs. Ie, for each button
  35668. * release.
  35669. * Override this method to provide functionality.
  35670. */
  35671. protected onButtonUp(evt: PointerEvent): void;
  35672. /**
  35673. * Called when window becomes inactive.
  35674. * Override this method to provide functionality.
  35675. */
  35676. protected onLostFocus(): void;
  35677. private _pointerInput;
  35678. private _observer;
  35679. private _onLostFocus;
  35680. private pointA;
  35681. private pointB;
  35682. }
  35683. }
  35684. declare module BABYLON {
  35685. /**
  35686. * Manage the pointers inputs to control an arc rotate camera.
  35687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35688. */
  35689. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35690. /**
  35691. * Defines the camera the input is attached to.
  35692. */
  35693. camera: ArcRotateCamera;
  35694. /**
  35695. * Gets the class name of the current input.
  35696. * @returns the class name
  35697. */
  35698. getClassName(): string;
  35699. /**
  35700. * Defines the buttons associated with the input to handle camera move.
  35701. */
  35702. buttons: number[];
  35703. /**
  35704. * Defines the pointer angular sensibility along the X axis or how fast is
  35705. * the camera rotating.
  35706. */
  35707. angularSensibilityX: number;
  35708. /**
  35709. * Defines the pointer angular sensibility along the Y axis or how fast is
  35710. * the camera rotating.
  35711. */
  35712. angularSensibilityY: number;
  35713. /**
  35714. * Defines the pointer pinch precision or how fast is the camera zooming.
  35715. */
  35716. pinchPrecision: number;
  35717. /**
  35718. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35719. * from 0.
  35720. * It defines the percentage of current camera.radius to use as delta when
  35721. * pinch zoom is used.
  35722. */
  35723. pinchDeltaPercentage: number;
  35724. /**
  35725. * Defines the pointer panning sensibility or how fast is the camera moving.
  35726. */
  35727. panningSensibility: number;
  35728. /**
  35729. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35730. */
  35731. multiTouchPanning: boolean;
  35732. /**
  35733. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35734. * zoom (pinch) through multitouch.
  35735. */
  35736. multiTouchPanAndZoom: boolean;
  35737. /**
  35738. * Revers pinch action direction.
  35739. */
  35740. pinchInwards: boolean;
  35741. private _isPanClick;
  35742. private _twoFingerActivityCount;
  35743. private _isPinching;
  35744. /**
  35745. * Called on pointer POINTERMOVE event if only a single touch is active.
  35746. */
  35747. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35748. /**
  35749. * Called on pointer POINTERDOUBLETAP event.
  35750. */
  35751. protected onDoubleTap(type: string): void;
  35752. /**
  35753. * Called on pointer POINTERMOVE event if multiple touches are active.
  35754. */
  35755. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35756. /**
  35757. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35758. * press.
  35759. */
  35760. protected onButtonDown(evt: PointerEvent): void;
  35761. /**
  35762. * Called each time a new POINTERUP event occurs. Ie, for each button
  35763. * release.
  35764. */
  35765. protected onButtonUp(evt: PointerEvent): void;
  35766. /**
  35767. * Called when window becomes inactive.
  35768. */
  35769. protected onLostFocus(): void;
  35770. }
  35771. }
  35772. declare module BABYLON {
  35773. /**
  35774. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35776. */
  35777. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35778. /**
  35779. * Defines the camera the input is attached to.
  35780. */
  35781. camera: ArcRotateCamera;
  35782. /**
  35783. * Defines the list of key codes associated with the up action (increase alpha)
  35784. */
  35785. keysUp: number[];
  35786. /**
  35787. * Defines the list of key codes associated with the down action (decrease alpha)
  35788. */
  35789. keysDown: number[];
  35790. /**
  35791. * Defines the list of key codes associated with the left action (increase beta)
  35792. */
  35793. keysLeft: number[];
  35794. /**
  35795. * Defines the list of key codes associated with the right action (decrease beta)
  35796. */
  35797. keysRight: number[];
  35798. /**
  35799. * Defines the list of key codes associated with the reset action.
  35800. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35801. */
  35802. keysReset: number[];
  35803. /**
  35804. * Defines the panning sensibility of the inputs.
  35805. * (How fast is the camera paning)
  35806. */
  35807. panningSensibility: number;
  35808. /**
  35809. * Defines the zooming sensibility of the inputs.
  35810. * (How fast is the camera zooming)
  35811. */
  35812. zoomingSensibility: number;
  35813. /**
  35814. * Defines wether maintaining the alt key down switch the movement mode from
  35815. * orientation to zoom.
  35816. */
  35817. useAltToZoom: boolean;
  35818. /**
  35819. * Rotation speed of the camera
  35820. */
  35821. angularSpeed: number;
  35822. private _keys;
  35823. private _ctrlPressed;
  35824. private _altPressed;
  35825. private _onCanvasBlurObserver;
  35826. private _onKeyboardObserver;
  35827. private _engine;
  35828. private _scene;
  35829. /**
  35830. * Attach the input controls to a specific dom element to get the input from.
  35831. * @param element Defines the element the controls should be listened from
  35832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35833. */
  35834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35835. /**
  35836. * Detach the current controls from the specified dom element.
  35837. * @param element Defines the element to stop listening the inputs from
  35838. */
  35839. detachControl(element: Nullable<HTMLElement>): void;
  35840. /**
  35841. * Update the current camera state depending on the inputs that have been used this frame.
  35842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35843. */
  35844. checkInputs(): void;
  35845. /**
  35846. * Gets the class name of the current intput.
  35847. * @returns the class name
  35848. */
  35849. getClassName(): string;
  35850. /**
  35851. * Get the friendly name associated with the input class.
  35852. * @returns the input friendly name
  35853. */
  35854. getSimpleName(): string;
  35855. }
  35856. }
  35857. declare module BABYLON {
  35858. /**
  35859. * Manage the mouse wheel inputs to control an arc rotate camera.
  35860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35861. */
  35862. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35863. /**
  35864. * Defines the camera the input is attached to.
  35865. */
  35866. camera: ArcRotateCamera;
  35867. /**
  35868. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35869. */
  35870. wheelPrecision: number;
  35871. /**
  35872. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35873. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35874. */
  35875. wheelDeltaPercentage: number;
  35876. private _wheel;
  35877. private _observer;
  35878. private computeDeltaFromMouseWheelLegacyEvent;
  35879. /**
  35880. * Attach the input controls to a specific dom element to get the input from.
  35881. * @param element Defines the element the controls should be listened from
  35882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35883. */
  35884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35885. /**
  35886. * Detach the current controls from the specified dom element.
  35887. * @param element Defines the element to stop listening the inputs from
  35888. */
  35889. detachControl(element: Nullable<HTMLElement>): void;
  35890. /**
  35891. * Gets the class name of the current intput.
  35892. * @returns the class name
  35893. */
  35894. getClassName(): string;
  35895. /**
  35896. * Get the friendly name associated with the input class.
  35897. * @returns the input friendly name
  35898. */
  35899. getSimpleName(): string;
  35900. }
  35901. }
  35902. declare module BABYLON {
  35903. /**
  35904. * Default Inputs manager for the ArcRotateCamera.
  35905. * It groups all the default supported inputs for ease of use.
  35906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35907. */
  35908. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35909. /**
  35910. * Instantiates a new ArcRotateCameraInputsManager.
  35911. * @param camera Defines the camera the inputs belong to
  35912. */
  35913. constructor(camera: ArcRotateCamera);
  35914. /**
  35915. * Add mouse wheel input support to the input manager.
  35916. * @returns the current input manager
  35917. */
  35918. addMouseWheel(): ArcRotateCameraInputsManager;
  35919. /**
  35920. * Add pointers input support to the input manager.
  35921. * @returns the current input manager
  35922. */
  35923. addPointers(): ArcRotateCameraInputsManager;
  35924. /**
  35925. * Add keyboard input support to the input manager.
  35926. * @returns the current input manager
  35927. */
  35928. addKeyboard(): ArcRotateCameraInputsManager;
  35929. }
  35930. }
  35931. declare module BABYLON {
  35932. /**
  35933. * This represents an orbital type of camera.
  35934. *
  35935. * 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.
  35936. * 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.
  35937. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35938. */
  35939. export class ArcRotateCamera extends TargetCamera {
  35940. /**
  35941. * Defines the rotation angle of the camera along the longitudinal axis.
  35942. */
  35943. alpha: number;
  35944. /**
  35945. * Defines the rotation angle of the camera along the latitudinal axis.
  35946. */
  35947. beta: number;
  35948. /**
  35949. * Defines the radius of the camera from it s target point.
  35950. */
  35951. radius: number;
  35952. protected _target: Vector3;
  35953. protected _targetHost: Nullable<AbstractMesh>;
  35954. /**
  35955. * Defines the target point of the camera.
  35956. * The camera looks towards it form the radius distance.
  35957. */
  35958. target: Vector3;
  35959. /**
  35960. * Define the current local position of the camera in the scene
  35961. */
  35962. position: Vector3;
  35963. protected _upVector: Vector3;
  35964. protected _upToYMatrix: Matrix;
  35965. protected _YToUpMatrix: Matrix;
  35966. /**
  35967. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35968. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35969. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35970. */
  35971. upVector: Vector3;
  35972. /**
  35973. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35974. */
  35975. setMatUp(): void;
  35976. /**
  35977. * Current inertia value on the longitudinal axis.
  35978. * The bigger this number the longer it will take for the camera to stop.
  35979. */
  35980. inertialAlphaOffset: number;
  35981. /**
  35982. * Current inertia value on the latitudinal axis.
  35983. * The bigger this number the longer it will take for the camera to stop.
  35984. */
  35985. inertialBetaOffset: number;
  35986. /**
  35987. * Current inertia value on the radius axis.
  35988. * The bigger this number the longer it will take for the camera to stop.
  35989. */
  35990. inertialRadiusOffset: number;
  35991. /**
  35992. * Minimum allowed angle on the longitudinal axis.
  35993. * This can help limiting how the Camera is able to move in the scene.
  35994. */
  35995. lowerAlphaLimit: Nullable<number>;
  35996. /**
  35997. * Maximum allowed angle on the longitudinal axis.
  35998. * This can help limiting how the Camera is able to move in the scene.
  35999. */
  36000. upperAlphaLimit: Nullable<number>;
  36001. /**
  36002. * Minimum allowed angle on the latitudinal axis.
  36003. * This can help limiting how the Camera is able to move in the scene.
  36004. */
  36005. lowerBetaLimit: number;
  36006. /**
  36007. * Maximum allowed angle on the latitudinal axis.
  36008. * This can help limiting how the Camera is able to move in the scene.
  36009. */
  36010. upperBetaLimit: number;
  36011. /**
  36012. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36013. * This can help limiting how the Camera is able to move in the scene.
  36014. */
  36015. lowerRadiusLimit: Nullable<number>;
  36016. /**
  36017. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36018. * This can help limiting how the Camera is able to move in the scene.
  36019. */
  36020. upperRadiusLimit: Nullable<number>;
  36021. /**
  36022. * Defines the current inertia value used during panning of the camera along the X axis.
  36023. */
  36024. inertialPanningX: number;
  36025. /**
  36026. * Defines the current inertia value used during panning of the camera along the Y axis.
  36027. */
  36028. inertialPanningY: number;
  36029. /**
  36030. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36031. * Basically if your fingers moves away from more than this distance you will be considered
  36032. * in pinch mode.
  36033. */
  36034. pinchToPanMaxDistance: number;
  36035. /**
  36036. * Defines the maximum distance the camera can pan.
  36037. * This could help keeping the cammera always in your scene.
  36038. */
  36039. panningDistanceLimit: Nullable<number>;
  36040. /**
  36041. * Defines the target of the camera before paning.
  36042. */
  36043. panningOriginTarget: Vector3;
  36044. /**
  36045. * Defines the value of the inertia used during panning.
  36046. * 0 would mean stop inertia and one would mean no decelleration at all.
  36047. */
  36048. panningInertia: number;
  36049. /**
  36050. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36051. */
  36052. angularSensibilityX: number;
  36053. /**
  36054. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36055. */
  36056. angularSensibilityY: number;
  36057. /**
  36058. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36059. */
  36060. pinchPrecision: number;
  36061. /**
  36062. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36063. * It will be used instead of pinchDeltaPrecision if different from 0.
  36064. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36065. */
  36066. pinchDeltaPercentage: number;
  36067. /**
  36068. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36069. */
  36070. panningSensibility: number;
  36071. /**
  36072. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36073. */
  36074. keysUp: number[];
  36075. /**
  36076. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36077. */
  36078. keysDown: number[];
  36079. /**
  36080. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36081. */
  36082. keysLeft: number[];
  36083. /**
  36084. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36085. */
  36086. keysRight: number[];
  36087. /**
  36088. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36089. */
  36090. wheelPrecision: number;
  36091. /**
  36092. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36093. * It will be used instead of pinchDeltaPrecision if different from 0.
  36094. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36095. */
  36096. wheelDeltaPercentage: number;
  36097. /**
  36098. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36099. */
  36100. zoomOnFactor: number;
  36101. /**
  36102. * Defines a screen offset for the camera position.
  36103. */
  36104. targetScreenOffset: Vector2;
  36105. /**
  36106. * Allows the camera to be completely reversed.
  36107. * If false the camera can not arrive upside down.
  36108. */
  36109. allowUpsideDown: boolean;
  36110. /**
  36111. * Define if double tap/click is used to restore the previously saved state of the camera.
  36112. */
  36113. useInputToRestoreState: boolean;
  36114. /** @hidden */
  36115. _viewMatrix: Matrix;
  36116. /** @hidden */
  36117. _useCtrlForPanning: boolean;
  36118. /** @hidden */
  36119. _panningMouseButton: number;
  36120. /**
  36121. * Defines the input associated to the camera.
  36122. */
  36123. inputs: ArcRotateCameraInputsManager;
  36124. /** @hidden */
  36125. _reset: () => void;
  36126. /**
  36127. * Defines the allowed panning axis.
  36128. */
  36129. panningAxis: Vector3;
  36130. protected _localDirection: Vector3;
  36131. protected _transformedDirection: Vector3;
  36132. private _bouncingBehavior;
  36133. /**
  36134. * Gets the bouncing behavior of the camera if it has been enabled.
  36135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36136. */
  36137. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36138. /**
  36139. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36141. */
  36142. useBouncingBehavior: boolean;
  36143. private _framingBehavior;
  36144. /**
  36145. * Gets the framing behavior of the camera if it has been enabled.
  36146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36147. */
  36148. readonly framingBehavior: Nullable<FramingBehavior>;
  36149. /**
  36150. * Defines if the framing behavior of the camera is enabled on the camera.
  36151. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36152. */
  36153. useFramingBehavior: boolean;
  36154. private _autoRotationBehavior;
  36155. /**
  36156. * Gets the auto rotation behavior of the camera if it has been enabled.
  36157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36158. */
  36159. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36160. /**
  36161. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36163. */
  36164. useAutoRotationBehavior: boolean;
  36165. /**
  36166. * Observable triggered when the mesh target has been changed on the camera.
  36167. */
  36168. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36169. /**
  36170. * Event raised when the camera is colliding with a mesh.
  36171. */
  36172. onCollide: (collidedMesh: AbstractMesh) => void;
  36173. /**
  36174. * Defines whether the camera should check collision with the objects oh the scene.
  36175. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36176. */
  36177. checkCollisions: boolean;
  36178. /**
  36179. * Defines the collision radius of the camera.
  36180. * This simulates a sphere around the camera.
  36181. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36182. */
  36183. collisionRadius: Vector3;
  36184. protected _collider: Collider;
  36185. protected _previousPosition: Vector3;
  36186. protected _collisionVelocity: Vector3;
  36187. protected _newPosition: Vector3;
  36188. protected _previousAlpha: number;
  36189. protected _previousBeta: number;
  36190. protected _previousRadius: number;
  36191. protected _collisionTriggered: boolean;
  36192. protected _targetBoundingCenter: Nullable<Vector3>;
  36193. private _computationVector;
  36194. /**
  36195. * Instantiates a new ArcRotateCamera in a given scene
  36196. * @param name Defines the name of the camera
  36197. * @param alpha Defines the camera rotation along the logitudinal axis
  36198. * @param beta Defines the camera rotation along the latitudinal axis
  36199. * @param radius Defines the camera distance from its target
  36200. * @param target Defines the camera target
  36201. * @param scene Defines the scene the camera belongs to
  36202. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36203. */
  36204. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36205. /** @hidden */
  36206. _initCache(): void;
  36207. /** @hidden */
  36208. _updateCache(ignoreParentClass?: boolean): void;
  36209. protected _getTargetPosition(): Vector3;
  36210. private _storedAlpha;
  36211. private _storedBeta;
  36212. private _storedRadius;
  36213. private _storedTarget;
  36214. /**
  36215. * Stores the current state of the camera (alpha, beta, radius and target)
  36216. * @returns the camera itself
  36217. */
  36218. storeState(): Camera;
  36219. /**
  36220. * @hidden
  36221. * Restored camera state. You must call storeState() first
  36222. */
  36223. _restoreStateValues(): boolean;
  36224. /** @hidden */
  36225. _isSynchronizedViewMatrix(): boolean;
  36226. /**
  36227. * Attached controls to the current camera.
  36228. * @param element Defines the element the controls should be listened from
  36229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36230. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36231. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36232. */
  36233. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36234. /**
  36235. * Detach the current controls from the camera.
  36236. * The camera will stop reacting to inputs.
  36237. * @param element Defines the element to stop listening the inputs from
  36238. */
  36239. detachControl(element: HTMLElement): void;
  36240. /** @hidden */
  36241. _checkInputs(): void;
  36242. protected _checkLimits(): void;
  36243. /**
  36244. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36245. */
  36246. rebuildAnglesAndRadius(): void;
  36247. /**
  36248. * Use a position to define the current camera related information like aplha, beta and radius
  36249. * @param position Defines the position to set the camera at
  36250. */
  36251. setPosition(position: Vector3): void;
  36252. /**
  36253. * Defines the target the camera should look at.
  36254. * This will automatically adapt alpha beta and radius to fit within the new target.
  36255. * @param target Defines the new target as a Vector or a mesh
  36256. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36257. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36258. */
  36259. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36260. /** @hidden */
  36261. _getViewMatrix(): Matrix;
  36262. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36263. /**
  36264. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36265. * @param meshes Defines the mesh to zoom on
  36266. * @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)
  36267. */
  36268. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36269. /**
  36270. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36271. * The target will be changed but the radius
  36272. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36273. * @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)
  36274. */
  36275. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36276. min: Vector3;
  36277. max: Vector3;
  36278. distance: number;
  36279. }, doNotUpdateMaxZ?: boolean): void;
  36280. /**
  36281. * @override
  36282. * Override Camera.createRigCamera
  36283. */
  36284. createRigCamera(name: string, cameraIndex: number): Camera;
  36285. /**
  36286. * @hidden
  36287. * @override
  36288. * Override Camera._updateRigCameras
  36289. */
  36290. _updateRigCameras(): void;
  36291. /**
  36292. * Destroy the camera and release the current resources hold by it.
  36293. */
  36294. dispose(): void;
  36295. /**
  36296. * Gets the current object class name.
  36297. * @return the class name
  36298. */
  36299. getClassName(): string;
  36300. }
  36301. }
  36302. declare module BABYLON {
  36303. /**
  36304. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36306. */
  36307. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36308. /**
  36309. * Gets the name of the behavior.
  36310. */
  36311. readonly name: string;
  36312. private _zoomStopsAnimation;
  36313. private _idleRotationSpeed;
  36314. private _idleRotationWaitTime;
  36315. private _idleRotationSpinupTime;
  36316. /**
  36317. * Sets the flag that indicates if user zooming should stop animation.
  36318. */
  36319. /**
  36320. * Gets the flag that indicates if user zooming should stop animation.
  36321. */
  36322. zoomStopsAnimation: boolean;
  36323. /**
  36324. * Sets the default speed at which the camera rotates around the model.
  36325. */
  36326. /**
  36327. * Gets the default speed at which the camera rotates around the model.
  36328. */
  36329. idleRotationSpeed: number;
  36330. /**
  36331. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36332. */
  36333. /**
  36334. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36335. */
  36336. idleRotationWaitTime: number;
  36337. /**
  36338. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36339. */
  36340. /**
  36341. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36342. */
  36343. idleRotationSpinupTime: number;
  36344. /**
  36345. * Gets a value indicating if the camera is currently rotating because of this behavior
  36346. */
  36347. readonly rotationInProgress: boolean;
  36348. private _onPrePointerObservableObserver;
  36349. private _onAfterCheckInputsObserver;
  36350. private _attachedCamera;
  36351. private _isPointerDown;
  36352. private _lastFrameTime;
  36353. private _lastInteractionTime;
  36354. private _cameraRotationSpeed;
  36355. /**
  36356. * Initializes the behavior.
  36357. */
  36358. init(): void;
  36359. /**
  36360. * Attaches the behavior to its arc rotate camera.
  36361. * @param camera Defines the camera to attach the behavior to
  36362. */
  36363. attach(camera: ArcRotateCamera): void;
  36364. /**
  36365. * Detaches the behavior from its current arc rotate camera.
  36366. */
  36367. detach(): void;
  36368. /**
  36369. * Returns true if user is scrolling.
  36370. * @return true if user is scrolling.
  36371. */
  36372. private _userIsZooming;
  36373. private _lastFrameRadius;
  36374. private _shouldAnimationStopForInteraction;
  36375. /**
  36376. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36377. */
  36378. private _applyUserInteraction;
  36379. private _userIsMoving;
  36380. }
  36381. }
  36382. declare module BABYLON {
  36383. /**
  36384. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36385. */
  36386. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36387. private ui;
  36388. /**
  36389. * The name of the behavior
  36390. */
  36391. name: string;
  36392. /**
  36393. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36394. */
  36395. distanceAwayFromFace: number;
  36396. /**
  36397. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36398. */
  36399. distanceAwayFromBottomOfFace: number;
  36400. private _faceVectors;
  36401. private _target;
  36402. private _scene;
  36403. private _onRenderObserver;
  36404. private _tmpMatrix;
  36405. private _tmpVector;
  36406. /**
  36407. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36408. * @param ui The transform node that should be attched to the mesh
  36409. */
  36410. constructor(ui: TransformNode);
  36411. /**
  36412. * Initializes the behavior
  36413. */
  36414. init(): void;
  36415. private _closestFace;
  36416. private _zeroVector;
  36417. private _lookAtTmpMatrix;
  36418. private _lookAtToRef;
  36419. /**
  36420. * Attaches the AttachToBoxBehavior to the passed in mesh
  36421. * @param target The mesh that the specified node will be attached to
  36422. */
  36423. attach(target: Mesh): void;
  36424. /**
  36425. * Detaches the behavior from the mesh
  36426. */
  36427. detach(): void;
  36428. }
  36429. }
  36430. declare module BABYLON {
  36431. /**
  36432. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36433. */
  36434. export class FadeInOutBehavior implements Behavior<Mesh> {
  36435. /**
  36436. * Time in milliseconds to delay before fading in (Default: 0)
  36437. */
  36438. delay: number;
  36439. /**
  36440. * Time in milliseconds for the mesh to fade in (Default: 300)
  36441. */
  36442. fadeInTime: number;
  36443. private _millisecondsPerFrame;
  36444. private _hovered;
  36445. private _hoverValue;
  36446. private _ownerNode;
  36447. /**
  36448. * Instatiates the FadeInOutBehavior
  36449. */
  36450. constructor();
  36451. /**
  36452. * The name of the behavior
  36453. */
  36454. readonly name: string;
  36455. /**
  36456. * Initializes the behavior
  36457. */
  36458. init(): void;
  36459. /**
  36460. * Attaches the fade behavior on the passed in mesh
  36461. * @param ownerNode The mesh that will be faded in/out once attached
  36462. */
  36463. attach(ownerNode: Mesh): void;
  36464. /**
  36465. * Detaches the behavior from the mesh
  36466. */
  36467. detach(): void;
  36468. /**
  36469. * Triggers the mesh to begin fading in or out
  36470. * @param value if the object should fade in or out (true to fade in)
  36471. */
  36472. fadeIn(value: boolean): void;
  36473. private _update;
  36474. private _setAllVisibility;
  36475. }
  36476. }
  36477. declare module BABYLON {
  36478. /**
  36479. * Class containing a set of static utilities functions for managing Pivots
  36480. * @hidden
  36481. */
  36482. export class PivotTools {
  36483. private static _PivotCached;
  36484. private static _OldPivotPoint;
  36485. private static _PivotTranslation;
  36486. private static _PivotTmpVector;
  36487. /** @hidden */
  36488. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36489. /** @hidden */
  36490. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36491. }
  36492. }
  36493. declare module BABYLON {
  36494. /**
  36495. * Class containing static functions to help procedurally build meshes
  36496. */
  36497. export class PlaneBuilder {
  36498. /**
  36499. * Creates a plane mesh
  36500. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36501. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36502. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36504. * * 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
  36505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36506. * @param name defines the name of the mesh
  36507. * @param options defines the options used to create the mesh
  36508. * @param scene defines the hosting scene
  36509. * @returns the plane mesh
  36510. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36511. */
  36512. static CreatePlane(name: string, options: {
  36513. size?: number;
  36514. width?: number;
  36515. height?: number;
  36516. sideOrientation?: number;
  36517. frontUVs?: Vector4;
  36518. backUVs?: Vector4;
  36519. updatable?: boolean;
  36520. sourcePlane?: Plane;
  36521. }, scene?: Nullable<Scene>): Mesh;
  36522. }
  36523. }
  36524. declare module BABYLON {
  36525. /**
  36526. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36527. */
  36528. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36529. private static _AnyMouseID;
  36530. /**
  36531. * Abstract mesh the behavior is set on
  36532. */
  36533. attachedNode: AbstractMesh;
  36534. private _dragPlane;
  36535. private _scene;
  36536. private _pointerObserver;
  36537. private _beforeRenderObserver;
  36538. private static _planeScene;
  36539. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36540. /**
  36541. * 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)
  36542. */
  36543. maxDragAngle: number;
  36544. /**
  36545. * @hidden
  36546. */
  36547. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36548. /**
  36549. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36550. */
  36551. currentDraggingPointerID: number;
  36552. /**
  36553. * The last position where the pointer hit the drag plane in world space
  36554. */
  36555. lastDragPosition: Vector3;
  36556. /**
  36557. * If the behavior is currently in a dragging state
  36558. */
  36559. dragging: boolean;
  36560. /**
  36561. * 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)
  36562. */
  36563. dragDeltaRatio: number;
  36564. /**
  36565. * If the drag plane orientation should be updated during the dragging (Default: true)
  36566. */
  36567. updateDragPlane: boolean;
  36568. private _debugMode;
  36569. private _moving;
  36570. /**
  36571. * Fires each time the attached mesh is dragged with the pointer
  36572. * * delta between last drag position and current drag position in world space
  36573. * * dragDistance along the drag axis
  36574. * * dragPlaneNormal normal of the current drag plane used during the drag
  36575. * * dragPlanePoint in world space where the drag intersects the drag plane
  36576. */
  36577. onDragObservable: Observable<{
  36578. delta: Vector3;
  36579. dragPlanePoint: Vector3;
  36580. dragPlaneNormal: Vector3;
  36581. dragDistance: number;
  36582. pointerId: number;
  36583. }>;
  36584. /**
  36585. * Fires each time a drag begins (eg. mouse down on mesh)
  36586. */
  36587. onDragStartObservable: Observable<{
  36588. dragPlanePoint: Vector3;
  36589. pointerId: number;
  36590. }>;
  36591. /**
  36592. * Fires each time a drag ends (eg. mouse release after drag)
  36593. */
  36594. onDragEndObservable: Observable<{
  36595. dragPlanePoint: Vector3;
  36596. pointerId: number;
  36597. }>;
  36598. /**
  36599. * If the attached mesh should be moved when dragged
  36600. */
  36601. moveAttached: boolean;
  36602. /**
  36603. * If the drag behavior will react to drag events (Default: true)
  36604. */
  36605. enabled: boolean;
  36606. /**
  36607. * If pointer events should start and release the drag (Default: true)
  36608. */
  36609. startAndReleaseDragOnPointerEvents: boolean;
  36610. /**
  36611. * If camera controls should be detached during the drag
  36612. */
  36613. detachCameraControls: boolean;
  36614. /**
  36615. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36616. */
  36617. useObjectOrienationForDragging: boolean;
  36618. private _options;
  36619. /**
  36620. * Creates a pointer drag behavior that can be attached to a mesh
  36621. * @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)
  36622. */
  36623. constructor(options?: {
  36624. dragAxis?: Vector3;
  36625. dragPlaneNormal?: Vector3;
  36626. });
  36627. /**
  36628. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36629. */
  36630. validateDrag: (targetPosition: Vector3) => boolean;
  36631. /**
  36632. * The name of the behavior
  36633. */
  36634. readonly name: string;
  36635. /**
  36636. * Initializes the behavior
  36637. */
  36638. init(): void;
  36639. private _tmpVector;
  36640. private _alternatePickedPoint;
  36641. private _worldDragAxis;
  36642. private _targetPosition;
  36643. private _attachedElement;
  36644. /**
  36645. * Attaches the drag behavior the passed in mesh
  36646. * @param ownerNode The mesh that will be dragged around once attached
  36647. */
  36648. attach(ownerNode: AbstractMesh): void;
  36649. /**
  36650. * Force relase the drag action by code.
  36651. */
  36652. releaseDrag(): void;
  36653. private _startDragRay;
  36654. private _lastPointerRay;
  36655. /**
  36656. * Simulates the start of a pointer drag event on the behavior
  36657. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36658. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36659. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36660. */
  36661. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36662. private _startDrag;
  36663. private _dragDelta;
  36664. private _moveDrag;
  36665. private _pickWithRayOnDragPlane;
  36666. private _pointA;
  36667. private _pointB;
  36668. private _pointC;
  36669. private _lineA;
  36670. private _lineB;
  36671. private _localAxis;
  36672. private _lookAt;
  36673. private _updateDragPlanePosition;
  36674. /**
  36675. * Detaches the behavior from the mesh
  36676. */
  36677. detach(): void;
  36678. }
  36679. }
  36680. declare module BABYLON {
  36681. /**
  36682. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36683. */
  36684. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36685. private _dragBehaviorA;
  36686. private _dragBehaviorB;
  36687. private _startDistance;
  36688. private _initialScale;
  36689. private _targetScale;
  36690. private _ownerNode;
  36691. private _sceneRenderObserver;
  36692. /**
  36693. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36694. */
  36695. constructor();
  36696. /**
  36697. * The name of the behavior
  36698. */
  36699. readonly name: string;
  36700. /**
  36701. * Initializes the behavior
  36702. */
  36703. init(): void;
  36704. private _getCurrentDistance;
  36705. /**
  36706. * Attaches the scale behavior the passed in mesh
  36707. * @param ownerNode The mesh that will be scaled around once attached
  36708. */
  36709. attach(ownerNode: Mesh): void;
  36710. /**
  36711. * Detaches the behavior from the mesh
  36712. */
  36713. detach(): void;
  36714. }
  36715. }
  36716. declare module BABYLON {
  36717. /**
  36718. * 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
  36719. */
  36720. export class SixDofDragBehavior implements Behavior<Mesh> {
  36721. private static _virtualScene;
  36722. private _ownerNode;
  36723. private _sceneRenderObserver;
  36724. private _scene;
  36725. private _targetPosition;
  36726. private _virtualOriginMesh;
  36727. private _virtualDragMesh;
  36728. private _pointerObserver;
  36729. private _moving;
  36730. private _startingOrientation;
  36731. /**
  36732. * 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)
  36733. */
  36734. private zDragFactor;
  36735. /**
  36736. * If the object should rotate to face the drag origin
  36737. */
  36738. rotateDraggedObject: boolean;
  36739. /**
  36740. * If the behavior is currently in a dragging state
  36741. */
  36742. dragging: boolean;
  36743. /**
  36744. * 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)
  36745. */
  36746. dragDeltaRatio: number;
  36747. /**
  36748. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36749. */
  36750. currentDraggingPointerID: number;
  36751. /**
  36752. * If camera controls should be detached during the drag
  36753. */
  36754. detachCameraControls: boolean;
  36755. /**
  36756. * Fires each time a drag starts
  36757. */
  36758. onDragStartObservable: Observable<{}>;
  36759. /**
  36760. * Fires each time a drag ends (eg. mouse release after drag)
  36761. */
  36762. onDragEndObservable: Observable<{}>;
  36763. /**
  36764. * 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
  36765. */
  36766. constructor();
  36767. /**
  36768. * The name of the behavior
  36769. */
  36770. readonly name: string;
  36771. /**
  36772. * Initializes the behavior
  36773. */
  36774. init(): void;
  36775. /**
  36776. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36777. */
  36778. private readonly _pointerCamera;
  36779. /**
  36780. * Attaches the scale behavior the passed in mesh
  36781. * @param ownerNode The mesh that will be scaled around once attached
  36782. */
  36783. attach(ownerNode: Mesh): void;
  36784. /**
  36785. * Detaches the behavior from the mesh
  36786. */
  36787. detach(): void;
  36788. }
  36789. }
  36790. declare module BABYLON {
  36791. /**
  36792. * Class used to apply inverse kinematics to bones
  36793. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36794. */
  36795. export class BoneIKController {
  36796. private static _tmpVecs;
  36797. private static _tmpQuat;
  36798. private static _tmpMats;
  36799. /**
  36800. * Gets or sets the target mesh
  36801. */
  36802. targetMesh: AbstractMesh;
  36803. /** Gets or sets the mesh used as pole */
  36804. poleTargetMesh: AbstractMesh;
  36805. /**
  36806. * Gets or sets the bone used as pole
  36807. */
  36808. poleTargetBone: Nullable<Bone>;
  36809. /**
  36810. * Gets or sets the target position
  36811. */
  36812. targetPosition: Vector3;
  36813. /**
  36814. * Gets or sets the pole target position
  36815. */
  36816. poleTargetPosition: Vector3;
  36817. /**
  36818. * Gets or sets the pole target local offset
  36819. */
  36820. poleTargetLocalOffset: Vector3;
  36821. /**
  36822. * Gets or sets the pole angle
  36823. */
  36824. poleAngle: number;
  36825. /**
  36826. * Gets or sets the mesh associated with the controller
  36827. */
  36828. mesh: AbstractMesh;
  36829. /**
  36830. * 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)
  36831. */
  36832. slerpAmount: number;
  36833. private _bone1Quat;
  36834. private _bone1Mat;
  36835. private _bone2Ang;
  36836. private _bone1;
  36837. private _bone2;
  36838. private _bone1Length;
  36839. private _bone2Length;
  36840. private _maxAngle;
  36841. private _maxReach;
  36842. private _rightHandedSystem;
  36843. private _bendAxis;
  36844. private _slerping;
  36845. private _adjustRoll;
  36846. /**
  36847. * Gets or sets maximum allowed angle
  36848. */
  36849. maxAngle: number;
  36850. /**
  36851. * Creates a new BoneIKController
  36852. * @param mesh defines the mesh to control
  36853. * @param bone defines the bone to control
  36854. * @param options defines options to set up the controller
  36855. */
  36856. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36857. targetMesh?: AbstractMesh;
  36858. poleTargetMesh?: AbstractMesh;
  36859. poleTargetBone?: Bone;
  36860. poleTargetLocalOffset?: Vector3;
  36861. poleAngle?: number;
  36862. bendAxis?: Vector3;
  36863. maxAngle?: number;
  36864. slerpAmount?: number;
  36865. });
  36866. private _setMaxAngle;
  36867. /**
  36868. * Force the controller to update the bones
  36869. */
  36870. update(): void;
  36871. }
  36872. }
  36873. declare module BABYLON {
  36874. /**
  36875. * Class used to make a bone look toward a point in space
  36876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36877. */
  36878. export class BoneLookController {
  36879. private static _tmpVecs;
  36880. private static _tmpQuat;
  36881. private static _tmpMats;
  36882. /**
  36883. * The target Vector3 that the bone will look at
  36884. */
  36885. target: Vector3;
  36886. /**
  36887. * The mesh that the bone is attached to
  36888. */
  36889. mesh: AbstractMesh;
  36890. /**
  36891. * The bone that will be looking to the target
  36892. */
  36893. bone: Bone;
  36894. /**
  36895. * The up axis of the coordinate system that is used when the bone is rotated
  36896. */
  36897. upAxis: Vector3;
  36898. /**
  36899. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36900. */
  36901. upAxisSpace: Space;
  36902. /**
  36903. * Used to make an adjustment to the yaw of the bone
  36904. */
  36905. adjustYaw: number;
  36906. /**
  36907. * Used to make an adjustment to the pitch of the bone
  36908. */
  36909. adjustPitch: number;
  36910. /**
  36911. * Used to make an adjustment to the roll of the bone
  36912. */
  36913. adjustRoll: number;
  36914. /**
  36915. * 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)
  36916. */
  36917. slerpAmount: number;
  36918. private _minYaw;
  36919. private _maxYaw;
  36920. private _minPitch;
  36921. private _maxPitch;
  36922. private _minYawSin;
  36923. private _minYawCos;
  36924. private _maxYawSin;
  36925. private _maxYawCos;
  36926. private _midYawConstraint;
  36927. private _minPitchTan;
  36928. private _maxPitchTan;
  36929. private _boneQuat;
  36930. private _slerping;
  36931. private _transformYawPitch;
  36932. private _transformYawPitchInv;
  36933. private _firstFrameSkipped;
  36934. private _yawRange;
  36935. private _fowardAxis;
  36936. /**
  36937. * Gets or sets the minimum yaw angle that the bone can look to
  36938. */
  36939. minYaw: number;
  36940. /**
  36941. * Gets or sets the maximum yaw angle that the bone can look to
  36942. */
  36943. maxYaw: number;
  36944. /**
  36945. * Gets or sets the minimum pitch angle that the bone can look to
  36946. */
  36947. minPitch: number;
  36948. /**
  36949. * Gets or sets the maximum pitch angle that the bone can look to
  36950. */
  36951. maxPitch: number;
  36952. /**
  36953. * Create a BoneLookController
  36954. * @param mesh the mesh that the bone belongs to
  36955. * @param bone the bone that will be looking to the target
  36956. * @param target the target Vector3 to look at
  36957. * @param options optional settings:
  36958. * * maxYaw: the maximum angle the bone will yaw to
  36959. * * minYaw: the minimum angle the bone will yaw to
  36960. * * maxPitch: the maximum angle the bone will pitch to
  36961. * * minPitch: the minimum angle the bone will yaw to
  36962. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36963. * * upAxis: the up axis of the coordinate system
  36964. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36965. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36966. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36967. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36968. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36969. * * adjustRoll: used to make an adjustment to the roll of the bone
  36970. **/
  36971. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36972. maxYaw?: number;
  36973. minYaw?: number;
  36974. maxPitch?: number;
  36975. minPitch?: number;
  36976. slerpAmount?: number;
  36977. upAxis?: Vector3;
  36978. upAxisSpace?: Space;
  36979. yawAxis?: Vector3;
  36980. pitchAxis?: Vector3;
  36981. adjustYaw?: number;
  36982. adjustPitch?: number;
  36983. adjustRoll?: number;
  36984. });
  36985. /**
  36986. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36987. */
  36988. update(): void;
  36989. private _getAngleDiff;
  36990. private _getAngleBetween;
  36991. private _isAngleBetween;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. /**
  36996. * Manage the gamepad inputs to control an arc rotate camera.
  36997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36998. */
  36999. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37000. /**
  37001. * Defines the camera the input is attached to.
  37002. */
  37003. camera: ArcRotateCamera;
  37004. /**
  37005. * Defines the gamepad the input is gathering event from.
  37006. */
  37007. gamepad: Nullable<Gamepad>;
  37008. /**
  37009. * Defines the gamepad rotation sensiblity.
  37010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37011. */
  37012. gamepadRotationSensibility: number;
  37013. /**
  37014. * Defines the gamepad move sensiblity.
  37015. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37016. */
  37017. gamepadMoveSensibility: number;
  37018. private _onGamepadConnectedObserver;
  37019. private _onGamepadDisconnectedObserver;
  37020. /**
  37021. * Attach the input controls to a specific dom element to get the input from.
  37022. * @param element Defines the element the controls should be listened from
  37023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37024. */
  37025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37026. /**
  37027. * Detach the current controls from the specified dom element.
  37028. * @param element Defines the element to stop listening the inputs from
  37029. */
  37030. detachControl(element: Nullable<HTMLElement>): void;
  37031. /**
  37032. * Update the current camera state depending on the inputs that have been used this frame.
  37033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37034. */
  37035. checkInputs(): void;
  37036. /**
  37037. * Gets the class name of the current intput.
  37038. * @returns the class name
  37039. */
  37040. getClassName(): string;
  37041. /**
  37042. * Get the friendly name associated with the input class.
  37043. * @returns the input friendly name
  37044. */
  37045. getSimpleName(): string;
  37046. }
  37047. }
  37048. declare module BABYLON {
  37049. interface ArcRotateCameraInputsManager {
  37050. /**
  37051. * Add orientation input support to the input manager.
  37052. * @returns the current input manager
  37053. */
  37054. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37055. }
  37056. /**
  37057. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37059. */
  37060. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37061. /**
  37062. * Defines the camera the input is attached to.
  37063. */
  37064. camera: ArcRotateCamera;
  37065. /**
  37066. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37067. */
  37068. alphaCorrection: number;
  37069. /**
  37070. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37071. */
  37072. gammaCorrection: number;
  37073. private _alpha;
  37074. private _gamma;
  37075. private _dirty;
  37076. private _deviceOrientationHandler;
  37077. /**
  37078. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37079. */
  37080. constructor();
  37081. /**
  37082. * Attach the input controls to a specific dom element to get the input from.
  37083. * @param element Defines the element the controls should be listened from
  37084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37085. */
  37086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37087. /** @hidden */
  37088. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37089. /**
  37090. * Update the current camera state depending on the inputs that have been used this frame.
  37091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37092. */
  37093. checkInputs(): void;
  37094. /**
  37095. * Detach the current controls from the specified dom element.
  37096. * @param element Defines the element to stop listening the inputs from
  37097. */
  37098. detachControl(element: Nullable<HTMLElement>): void;
  37099. /**
  37100. * Gets the class name of the current intput.
  37101. * @returns the class name
  37102. */
  37103. getClassName(): string;
  37104. /**
  37105. * Get the friendly name associated with the input class.
  37106. * @returns the input friendly name
  37107. */
  37108. getSimpleName(): string;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * Listen to mouse events to control the camera.
  37114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37115. */
  37116. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37117. /**
  37118. * Defines the camera the input is attached to.
  37119. */
  37120. camera: FlyCamera;
  37121. /**
  37122. * Defines if touch is enabled. (Default is true.)
  37123. */
  37124. touchEnabled: boolean;
  37125. /**
  37126. * Defines the buttons associated with the input to handle camera rotation.
  37127. */
  37128. buttons: number[];
  37129. /**
  37130. * Assign buttons for Yaw control.
  37131. */
  37132. buttonsYaw: number[];
  37133. /**
  37134. * Assign buttons for Pitch control.
  37135. */
  37136. buttonsPitch: number[];
  37137. /**
  37138. * Assign buttons for Roll control.
  37139. */
  37140. buttonsRoll: number[];
  37141. /**
  37142. * Detect if any button is being pressed while mouse is moved.
  37143. * -1 = Mouse locked.
  37144. * 0 = Left button.
  37145. * 1 = Middle Button.
  37146. * 2 = Right Button.
  37147. */
  37148. activeButton: number;
  37149. /**
  37150. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37151. * Higher values reduce its sensitivity.
  37152. */
  37153. angularSensibility: number;
  37154. private _mousemoveCallback;
  37155. private _observer;
  37156. private _rollObserver;
  37157. private previousPosition;
  37158. private noPreventDefault;
  37159. private element;
  37160. /**
  37161. * Listen to mouse events to control the camera.
  37162. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37164. */
  37165. constructor(touchEnabled?: boolean);
  37166. /**
  37167. * Attach the mouse control to the HTML DOM element.
  37168. * @param element Defines the element that listens to the input events.
  37169. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37170. */
  37171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37172. /**
  37173. * Detach the current controls from the specified dom element.
  37174. * @param element Defines the element to stop listening the inputs from
  37175. */
  37176. detachControl(element: Nullable<HTMLElement>): void;
  37177. /**
  37178. * Gets the class name of the current input.
  37179. * @returns the class name.
  37180. */
  37181. getClassName(): string;
  37182. /**
  37183. * Get the friendly name associated with the input class.
  37184. * @returns the input's friendly name.
  37185. */
  37186. getSimpleName(): string;
  37187. private _pointerInput;
  37188. private _onMouseMove;
  37189. /**
  37190. * Rotate camera by mouse offset.
  37191. */
  37192. private rotateCamera;
  37193. }
  37194. }
  37195. declare module BABYLON {
  37196. /**
  37197. * Default Inputs manager for the FlyCamera.
  37198. * It groups all the default supported inputs for ease of use.
  37199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37200. */
  37201. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37202. /**
  37203. * Instantiates a new FlyCameraInputsManager.
  37204. * @param camera Defines the camera the inputs belong to.
  37205. */
  37206. constructor(camera: FlyCamera);
  37207. /**
  37208. * Add keyboard input support to the input manager.
  37209. * @returns the new FlyCameraKeyboardMoveInput().
  37210. */
  37211. addKeyboard(): FlyCameraInputsManager;
  37212. /**
  37213. * Add mouse input support to the input manager.
  37214. * @param touchEnabled Enable touch screen support.
  37215. * @returns the new FlyCameraMouseInput().
  37216. */
  37217. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37223. * such as in a 3D Space Shooter or a Flight Simulator.
  37224. */
  37225. export class FlyCamera extends TargetCamera {
  37226. /**
  37227. * Define the collision ellipsoid of the camera.
  37228. * This is helpful for simulating a camera body, like a player's body.
  37229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37230. */
  37231. ellipsoid: Vector3;
  37232. /**
  37233. * Define an offset for the position of the ellipsoid around the camera.
  37234. * This can be helpful if the camera is attached away from the player's body center,
  37235. * such as at its head.
  37236. */
  37237. ellipsoidOffset: Vector3;
  37238. /**
  37239. * Enable or disable collisions of the camera with the rest of the scene objects.
  37240. */
  37241. checkCollisions: boolean;
  37242. /**
  37243. * Enable or disable gravity on the camera.
  37244. */
  37245. applyGravity: boolean;
  37246. /**
  37247. * Define the current direction the camera is moving to.
  37248. */
  37249. cameraDirection: Vector3;
  37250. /**
  37251. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37252. * This overrides and empties cameraRotation.
  37253. */
  37254. rotationQuaternion: Quaternion;
  37255. /**
  37256. * Track Roll to maintain the wanted Rolling when looking around.
  37257. */
  37258. _trackRoll: number;
  37259. /**
  37260. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37261. */
  37262. rollCorrect: number;
  37263. /**
  37264. * Mimic a banked turn, Rolling the camera when Yawing.
  37265. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37266. */
  37267. bankedTurn: boolean;
  37268. /**
  37269. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37270. */
  37271. bankedTurnLimit: number;
  37272. /**
  37273. * Value of 0 disables the banked Roll.
  37274. * Value of 1 is equal to the Yaw angle in radians.
  37275. */
  37276. bankedTurnMultiplier: number;
  37277. /**
  37278. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37279. */
  37280. inputs: FlyCameraInputsManager;
  37281. /**
  37282. * Gets the input sensibility for mouse input.
  37283. * Higher values reduce sensitivity.
  37284. */
  37285. /**
  37286. * Sets the input sensibility for a mouse input.
  37287. * Higher values reduce sensitivity.
  37288. */
  37289. angularSensibility: number;
  37290. /**
  37291. * Get the keys for camera movement forward.
  37292. */
  37293. /**
  37294. * Set the keys for camera movement forward.
  37295. */
  37296. keysForward: number[];
  37297. /**
  37298. * Get the keys for camera movement backward.
  37299. */
  37300. keysBackward: number[];
  37301. /**
  37302. * Get the keys for camera movement up.
  37303. */
  37304. /**
  37305. * Set the keys for camera movement up.
  37306. */
  37307. keysUp: number[];
  37308. /**
  37309. * Get the keys for camera movement down.
  37310. */
  37311. /**
  37312. * Set the keys for camera movement down.
  37313. */
  37314. keysDown: number[];
  37315. /**
  37316. * Get the keys for camera movement left.
  37317. */
  37318. /**
  37319. * Set the keys for camera movement left.
  37320. */
  37321. keysLeft: number[];
  37322. /**
  37323. * Set the keys for camera movement right.
  37324. */
  37325. /**
  37326. * Set the keys for camera movement right.
  37327. */
  37328. keysRight: number[];
  37329. /**
  37330. * Event raised when the camera collides with a mesh in the scene.
  37331. */
  37332. onCollide: (collidedMesh: AbstractMesh) => void;
  37333. private _collider;
  37334. private _needMoveForGravity;
  37335. private _oldPosition;
  37336. private _diffPosition;
  37337. private _newPosition;
  37338. /** @hidden */
  37339. _localDirection: Vector3;
  37340. /** @hidden */
  37341. _transformedDirection: Vector3;
  37342. /**
  37343. * Instantiates a FlyCamera.
  37344. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37345. * such as in a 3D Space Shooter or a Flight Simulator.
  37346. * @param name Define the name of the camera in the scene.
  37347. * @param position Define the starting position of the camera in the scene.
  37348. * @param scene Define the scene the camera belongs to.
  37349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37350. */
  37351. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37352. /**
  37353. * Attach a control to the HTML DOM element.
  37354. * @param element Defines the element that listens to the input events.
  37355. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37356. */
  37357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37358. /**
  37359. * Detach a control from the HTML DOM element.
  37360. * The camera will stop reacting to that input.
  37361. * @param element Defines the element that listens to the input events.
  37362. */
  37363. detachControl(element: HTMLElement): void;
  37364. private _collisionMask;
  37365. /**
  37366. * Get the mask that the camera ignores in collision events.
  37367. */
  37368. /**
  37369. * Set the mask that the camera ignores in collision events.
  37370. */
  37371. collisionMask: number;
  37372. /** @hidden */
  37373. _collideWithWorld(displacement: Vector3): void;
  37374. /** @hidden */
  37375. private _onCollisionPositionChange;
  37376. /** @hidden */
  37377. _checkInputs(): void;
  37378. /** @hidden */
  37379. _decideIfNeedsToMove(): boolean;
  37380. /** @hidden */
  37381. _updatePosition(): void;
  37382. /**
  37383. * Restore the Roll to its target value at the rate specified.
  37384. * @param rate - Higher means slower restoring.
  37385. * @hidden
  37386. */
  37387. restoreRoll(rate: number): void;
  37388. /**
  37389. * Destroy the camera and release the current resources held by it.
  37390. */
  37391. dispose(): void;
  37392. /**
  37393. * Get the current object class name.
  37394. * @returns the class name.
  37395. */
  37396. getClassName(): string;
  37397. }
  37398. }
  37399. declare module BABYLON {
  37400. /**
  37401. * Listen to keyboard events to control the camera.
  37402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37403. */
  37404. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37405. /**
  37406. * Defines the camera the input is attached to.
  37407. */
  37408. camera: FlyCamera;
  37409. /**
  37410. * The list of keyboard keys used to control the forward move of the camera.
  37411. */
  37412. keysForward: number[];
  37413. /**
  37414. * The list of keyboard keys used to control the backward move of the camera.
  37415. */
  37416. keysBackward: number[];
  37417. /**
  37418. * The list of keyboard keys used to control the forward move of the camera.
  37419. */
  37420. keysUp: number[];
  37421. /**
  37422. * The list of keyboard keys used to control the backward move of the camera.
  37423. */
  37424. keysDown: number[];
  37425. /**
  37426. * The list of keyboard keys used to control the right strafe move of the camera.
  37427. */
  37428. keysRight: number[];
  37429. /**
  37430. * The list of keyboard keys used to control the left strafe move of the camera.
  37431. */
  37432. keysLeft: number[];
  37433. private _keys;
  37434. private _onCanvasBlurObserver;
  37435. private _onKeyboardObserver;
  37436. private _engine;
  37437. private _scene;
  37438. /**
  37439. * Attach the input controls to a specific dom element to get the input from.
  37440. * @param element Defines the element the controls should be listened from
  37441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37442. */
  37443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37444. /**
  37445. * Detach the current controls from the specified dom element.
  37446. * @param element Defines the element to stop listening the inputs from
  37447. */
  37448. detachControl(element: Nullable<HTMLElement>): void;
  37449. /**
  37450. * Gets the class name of the current intput.
  37451. * @returns the class name
  37452. */
  37453. getClassName(): string;
  37454. /** @hidden */
  37455. _onLostFocus(e: FocusEvent): void;
  37456. /**
  37457. * Get the friendly name associated with the input class.
  37458. * @returns the input friendly name
  37459. */
  37460. getSimpleName(): string;
  37461. /**
  37462. * Update the current camera state depending on the inputs that have been used this frame.
  37463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37464. */
  37465. checkInputs(): void;
  37466. }
  37467. }
  37468. declare module BABYLON {
  37469. /**
  37470. * Manage the mouse wheel inputs to control a follow camera.
  37471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37472. */
  37473. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37474. /**
  37475. * Defines the camera the input is attached to.
  37476. */
  37477. camera: FollowCamera;
  37478. /**
  37479. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37480. */
  37481. axisControlRadius: boolean;
  37482. /**
  37483. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37484. */
  37485. axisControlHeight: boolean;
  37486. /**
  37487. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37488. */
  37489. axisControlRotation: boolean;
  37490. /**
  37491. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37492. * relation to mouseWheel events.
  37493. */
  37494. wheelPrecision: number;
  37495. /**
  37496. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37497. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37498. */
  37499. wheelDeltaPercentage: number;
  37500. private _wheel;
  37501. private _observer;
  37502. /**
  37503. * Attach the input controls to a specific dom element to get the input from.
  37504. * @param element Defines the element the controls should be listened from
  37505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37506. */
  37507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37508. /**
  37509. * Detach the current controls from the specified dom element.
  37510. * @param element Defines the element to stop listening the inputs from
  37511. */
  37512. detachControl(element: Nullable<HTMLElement>): void;
  37513. /**
  37514. * Gets the class name of the current intput.
  37515. * @returns the class name
  37516. */
  37517. getClassName(): string;
  37518. /**
  37519. * Get the friendly name associated with the input class.
  37520. * @returns the input friendly name
  37521. */
  37522. getSimpleName(): string;
  37523. }
  37524. }
  37525. declare module BABYLON {
  37526. /**
  37527. * Manage the pointers inputs to control an follow camera.
  37528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37529. */
  37530. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37531. /**
  37532. * Defines the camera the input is attached to.
  37533. */
  37534. camera: FollowCamera;
  37535. /**
  37536. * Gets the class name of the current input.
  37537. * @returns the class name
  37538. */
  37539. getClassName(): string;
  37540. /**
  37541. * Defines the pointer angular sensibility along the X axis or how fast is
  37542. * the camera rotating.
  37543. * A negative number will reverse the axis direction.
  37544. */
  37545. angularSensibilityX: number;
  37546. /**
  37547. * Defines the pointer angular sensibility along the Y axis or how fast is
  37548. * the camera rotating.
  37549. * A negative number will reverse the axis direction.
  37550. */
  37551. angularSensibilityY: number;
  37552. /**
  37553. * Defines the pointer pinch precision or how fast is the camera zooming.
  37554. * A negative number will reverse the axis direction.
  37555. */
  37556. pinchPrecision: number;
  37557. /**
  37558. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37559. * from 0.
  37560. * It defines the percentage of current camera.radius to use as delta when
  37561. * pinch zoom is used.
  37562. */
  37563. pinchDeltaPercentage: number;
  37564. /**
  37565. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37566. */
  37567. axisXControlRadius: boolean;
  37568. /**
  37569. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37570. */
  37571. axisXControlHeight: boolean;
  37572. /**
  37573. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37574. */
  37575. axisXControlRotation: boolean;
  37576. /**
  37577. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37578. */
  37579. axisYControlRadius: boolean;
  37580. /**
  37581. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37582. */
  37583. axisYControlHeight: boolean;
  37584. /**
  37585. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37586. */
  37587. axisYControlRotation: boolean;
  37588. /**
  37589. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37590. */
  37591. axisPinchControlRadius: boolean;
  37592. /**
  37593. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37594. */
  37595. axisPinchControlHeight: boolean;
  37596. /**
  37597. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37598. */
  37599. axisPinchControlRotation: boolean;
  37600. /**
  37601. * Log error messages if basic misconfiguration has occurred.
  37602. */
  37603. warningEnable: boolean;
  37604. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37605. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37606. private _warningCounter;
  37607. private _warning;
  37608. }
  37609. }
  37610. declare module BABYLON {
  37611. /**
  37612. * Default Inputs manager for the FollowCamera.
  37613. * It groups all the default supported inputs for ease of use.
  37614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37615. */
  37616. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37617. /**
  37618. * Instantiates a new FollowCameraInputsManager.
  37619. * @param camera Defines the camera the inputs belong to
  37620. */
  37621. constructor(camera: FollowCamera);
  37622. /**
  37623. * Add keyboard input support to the input manager.
  37624. * @returns the current input manager
  37625. */
  37626. addKeyboard(): FollowCameraInputsManager;
  37627. /**
  37628. * Add mouse wheel input support to the input manager.
  37629. * @returns the current input manager
  37630. */
  37631. addMouseWheel(): FollowCameraInputsManager;
  37632. /**
  37633. * Add pointers input support to the input manager.
  37634. * @returns the current input manager
  37635. */
  37636. addPointers(): FollowCameraInputsManager;
  37637. /**
  37638. * Add orientation input support to the input manager.
  37639. * @returns the current input manager
  37640. */
  37641. addVRDeviceOrientation(): FollowCameraInputsManager;
  37642. }
  37643. }
  37644. declare module BABYLON {
  37645. /**
  37646. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37647. * an arc rotate version arcFollowCamera are available.
  37648. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37649. */
  37650. export class FollowCamera extends TargetCamera {
  37651. /**
  37652. * Distance the follow camera should follow an object at
  37653. */
  37654. radius: number;
  37655. /**
  37656. * Minimum allowed distance of the camera to the axis of rotation
  37657. * (The camera can not get closer).
  37658. * This can help limiting how the Camera is able to move in the scene.
  37659. */
  37660. lowerRadiusLimit: Nullable<number>;
  37661. /**
  37662. * Maximum allowed distance of the camera to the axis of rotation
  37663. * (The camera can not get further).
  37664. * This can help limiting how the Camera is able to move in the scene.
  37665. */
  37666. upperRadiusLimit: Nullable<number>;
  37667. /**
  37668. * Define a rotation offset between the camera and the object it follows
  37669. */
  37670. rotationOffset: number;
  37671. /**
  37672. * Minimum allowed angle to camera position relative to target object.
  37673. * This can help limiting how the Camera is able to move in the scene.
  37674. */
  37675. lowerRotationOffsetLimit: Nullable<number>;
  37676. /**
  37677. * Maximum allowed angle to camera position relative to target object.
  37678. * This can help limiting how the Camera is able to move in the scene.
  37679. */
  37680. upperRotationOffsetLimit: Nullable<number>;
  37681. /**
  37682. * Define a height offset between the camera and the object it follows.
  37683. * It can help following an object from the top (like a car chaing a plane)
  37684. */
  37685. heightOffset: number;
  37686. /**
  37687. * Minimum allowed height of camera position relative to target object.
  37688. * This can help limiting how the Camera is able to move in the scene.
  37689. */
  37690. lowerHeightOffsetLimit: Nullable<number>;
  37691. /**
  37692. * Maximum allowed height of camera position relative to target object.
  37693. * This can help limiting how the Camera is able to move in the scene.
  37694. */
  37695. upperHeightOffsetLimit: Nullable<number>;
  37696. /**
  37697. * Define how fast the camera can accelerate to follow it s target.
  37698. */
  37699. cameraAcceleration: number;
  37700. /**
  37701. * Define the speed limit of the camera following an object.
  37702. */
  37703. maxCameraSpeed: number;
  37704. /**
  37705. * Define the target of the camera.
  37706. */
  37707. lockedTarget: Nullable<AbstractMesh>;
  37708. /**
  37709. * Defines the input associated with the camera.
  37710. */
  37711. inputs: FollowCameraInputsManager;
  37712. /**
  37713. * Instantiates the follow camera.
  37714. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37715. * @param name Define the name of the camera in the scene
  37716. * @param position Define the position of the camera
  37717. * @param scene Define the scene the camera belong to
  37718. * @param lockedTarget Define the target of the camera
  37719. */
  37720. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37721. private _follow;
  37722. /**
  37723. * Attached controls to the current camera.
  37724. * @param element Defines the element the controls should be listened from
  37725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37726. */
  37727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37728. /**
  37729. * Detach the current controls from the camera.
  37730. * The camera will stop reacting to inputs.
  37731. * @param element Defines the element to stop listening the inputs from
  37732. */
  37733. detachControl(element: HTMLElement): void;
  37734. /** @hidden */
  37735. _checkInputs(): void;
  37736. private _checkLimits;
  37737. /**
  37738. * Gets the camera class name.
  37739. * @returns the class name
  37740. */
  37741. getClassName(): string;
  37742. }
  37743. /**
  37744. * Arc Rotate version of the follow camera.
  37745. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37746. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37747. */
  37748. export class ArcFollowCamera extends TargetCamera {
  37749. /** The longitudinal angle of the camera */
  37750. alpha: number;
  37751. /** The latitudinal angle of the camera */
  37752. beta: number;
  37753. /** The radius of the camera from its target */
  37754. radius: number;
  37755. /** Define the camera target (the messh it should follow) */
  37756. target: Nullable<AbstractMesh>;
  37757. private _cartesianCoordinates;
  37758. /**
  37759. * Instantiates a new ArcFollowCamera
  37760. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37761. * @param name Define the name of the camera
  37762. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37763. * @param beta Define the rotation angle of the camera around the elevation axis
  37764. * @param radius Define the radius of the camera from its target point
  37765. * @param target Define the target of the camera
  37766. * @param scene Define the scene the camera belongs to
  37767. */
  37768. constructor(name: string,
  37769. /** The longitudinal angle of the camera */
  37770. alpha: number,
  37771. /** The latitudinal angle of the camera */
  37772. beta: number,
  37773. /** The radius of the camera from its target */
  37774. radius: number,
  37775. /** Define the camera target (the messh it should follow) */
  37776. target: Nullable<AbstractMesh>, scene: Scene);
  37777. private _follow;
  37778. /** @hidden */
  37779. _checkInputs(): void;
  37780. /**
  37781. * Returns the class name of the object.
  37782. * It is mostly used internally for serialization purposes.
  37783. */
  37784. getClassName(): string;
  37785. }
  37786. }
  37787. declare module BABYLON {
  37788. /**
  37789. * Manage the keyboard inputs to control the movement of a follow camera.
  37790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37791. */
  37792. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37793. /**
  37794. * Defines the camera the input is attached to.
  37795. */
  37796. camera: FollowCamera;
  37797. /**
  37798. * Defines the list of key codes associated with the up action (increase heightOffset)
  37799. */
  37800. keysHeightOffsetIncr: number[];
  37801. /**
  37802. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37803. */
  37804. keysHeightOffsetDecr: number[];
  37805. /**
  37806. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37807. */
  37808. keysHeightOffsetModifierAlt: boolean;
  37809. /**
  37810. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37811. */
  37812. keysHeightOffsetModifierCtrl: boolean;
  37813. /**
  37814. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37815. */
  37816. keysHeightOffsetModifierShift: boolean;
  37817. /**
  37818. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37819. */
  37820. keysRotationOffsetIncr: number[];
  37821. /**
  37822. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37823. */
  37824. keysRotationOffsetDecr: number[];
  37825. /**
  37826. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37827. */
  37828. keysRotationOffsetModifierAlt: boolean;
  37829. /**
  37830. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37831. */
  37832. keysRotationOffsetModifierCtrl: boolean;
  37833. /**
  37834. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37835. */
  37836. keysRotationOffsetModifierShift: boolean;
  37837. /**
  37838. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37839. */
  37840. keysRadiusIncr: number[];
  37841. /**
  37842. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37843. */
  37844. keysRadiusDecr: number[];
  37845. /**
  37846. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37847. */
  37848. keysRadiusModifierAlt: boolean;
  37849. /**
  37850. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37851. */
  37852. keysRadiusModifierCtrl: boolean;
  37853. /**
  37854. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37855. */
  37856. keysRadiusModifierShift: boolean;
  37857. /**
  37858. * Defines the rate of change of heightOffset.
  37859. */
  37860. heightSensibility: number;
  37861. /**
  37862. * Defines the rate of change of rotationOffset.
  37863. */
  37864. rotationSensibility: number;
  37865. /**
  37866. * Defines the rate of change of radius.
  37867. */
  37868. radiusSensibility: number;
  37869. private _keys;
  37870. private _ctrlPressed;
  37871. private _altPressed;
  37872. private _shiftPressed;
  37873. private _onCanvasBlurObserver;
  37874. private _onKeyboardObserver;
  37875. private _engine;
  37876. private _scene;
  37877. /**
  37878. * Attach the input controls to a specific dom element to get the input from.
  37879. * @param element Defines the element the controls should be listened from
  37880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37881. */
  37882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37883. /**
  37884. * Detach the current controls from the specified dom element.
  37885. * @param element Defines the element to stop listening the inputs from
  37886. */
  37887. detachControl(element: Nullable<HTMLElement>): void;
  37888. /**
  37889. * Update the current camera state depending on the inputs that have been used this frame.
  37890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37891. */
  37892. checkInputs(): void;
  37893. /**
  37894. * Gets the class name of the current input.
  37895. * @returns the class name
  37896. */
  37897. getClassName(): string;
  37898. /**
  37899. * Get the friendly name associated with the input class.
  37900. * @returns the input friendly name
  37901. */
  37902. getSimpleName(): string;
  37903. /**
  37904. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37905. * allow modification of the heightOffset value.
  37906. */
  37907. private _modifierHeightOffset;
  37908. /**
  37909. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37910. * allow modification of the rotationOffset value.
  37911. */
  37912. private _modifierRotationOffset;
  37913. /**
  37914. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37915. * allow modification of the radius value.
  37916. */
  37917. private _modifierRadius;
  37918. }
  37919. }
  37920. declare module BABYLON {
  37921. interface FreeCameraInputsManager {
  37922. /**
  37923. * @hidden
  37924. */
  37925. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37926. /**
  37927. * Add orientation input support to the input manager.
  37928. * @returns the current input manager
  37929. */
  37930. addDeviceOrientation(): FreeCameraInputsManager;
  37931. }
  37932. /**
  37933. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37934. * Screen rotation is taken into account.
  37935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37936. */
  37937. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37938. private _camera;
  37939. private _screenOrientationAngle;
  37940. private _constantTranform;
  37941. private _screenQuaternion;
  37942. private _alpha;
  37943. private _beta;
  37944. private _gamma;
  37945. /**
  37946. * Can be used to detect if a device orientation sensor is availible on a device
  37947. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37948. * @returns a promise that will resolve on orientation change
  37949. */
  37950. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37951. /**
  37952. * @hidden
  37953. */
  37954. _onDeviceOrientationChangedObservable: Observable<void>;
  37955. /**
  37956. * Instantiates a new input
  37957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37958. */
  37959. constructor();
  37960. /**
  37961. * Define the camera controlled by the input.
  37962. */
  37963. camera: FreeCamera;
  37964. /**
  37965. * Attach the input controls to a specific dom element to get the input from.
  37966. * @param element Defines the element the controls should be listened from
  37967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37968. */
  37969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37970. private _orientationChanged;
  37971. private _deviceOrientation;
  37972. /**
  37973. * Detach the current controls from the specified dom element.
  37974. * @param element Defines the element to stop listening the inputs from
  37975. */
  37976. detachControl(element: Nullable<HTMLElement>): void;
  37977. /**
  37978. * Update the current camera state depending on the inputs that have been used this frame.
  37979. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37980. */
  37981. checkInputs(): void;
  37982. /**
  37983. * Gets the class name of the current intput.
  37984. * @returns the class name
  37985. */
  37986. getClassName(): string;
  37987. /**
  37988. * Get the friendly name associated with the input class.
  37989. * @returns the input friendly name
  37990. */
  37991. getSimpleName(): string;
  37992. }
  37993. }
  37994. declare module BABYLON {
  37995. /**
  37996. * Manage the gamepad inputs to control a free camera.
  37997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37998. */
  37999. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38000. /**
  38001. * Define the camera the input is attached to.
  38002. */
  38003. camera: FreeCamera;
  38004. /**
  38005. * Define the Gamepad controlling the input
  38006. */
  38007. gamepad: Nullable<Gamepad>;
  38008. /**
  38009. * Defines the gamepad rotation sensiblity.
  38010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38011. */
  38012. gamepadAngularSensibility: number;
  38013. /**
  38014. * Defines the gamepad move sensiblity.
  38015. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38016. */
  38017. gamepadMoveSensibility: number;
  38018. private _onGamepadConnectedObserver;
  38019. private _onGamepadDisconnectedObserver;
  38020. private _cameraTransform;
  38021. private _deltaTransform;
  38022. private _vector3;
  38023. private _vector2;
  38024. /**
  38025. * Attach the input controls to a specific dom element to get the input from.
  38026. * @param element Defines the element the controls should be listened from
  38027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38028. */
  38029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38030. /**
  38031. * Detach the current controls from the specified dom element.
  38032. * @param element Defines the element to stop listening the inputs from
  38033. */
  38034. detachControl(element: Nullable<HTMLElement>): void;
  38035. /**
  38036. * Update the current camera state depending on the inputs that have been used this frame.
  38037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38038. */
  38039. checkInputs(): void;
  38040. /**
  38041. * Gets the class name of the current intput.
  38042. * @returns the class name
  38043. */
  38044. getClassName(): string;
  38045. /**
  38046. * Get the friendly name associated with the input class.
  38047. * @returns the input friendly name
  38048. */
  38049. getSimpleName(): string;
  38050. }
  38051. }
  38052. declare module BABYLON {
  38053. /**
  38054. * Defines the potential axis of a Joystick
  38055. */
  38056. export enum JoystickAxis {
  38057. /** X axis */
  38058. X = 0,
  38059. /** Y axis */
  38060. Y = 1,
  38061. /** Z axis */
  38062. Z = 2
  38063. }
  38064. /**
  38065. * Class used to define virtual joystick (used in touch mode)
  38066. */
  38067. export class VirtualJoystick {
  38068. /**
  38069. * Gets or sets a boolean indicating that left and right values must be inverted
  38070. */
  38071. reverseLeftRight: boolean;
  38072. /**
  38073. * Gets or sets a boolean indicating that up and down values must be inverted
  38074. */
  38075. reverseUpDown: boolean;
  38076. /**
  38077. * Gets the offset value for the position (ie. the change of the position value)
  38078. */
  38079. deltaPosition: Vector3;
  38080. /**
  38081. * Gets a boolean indicating if the virtual joystick was pressed
  38082. */
  38083. pressed: boolean;
  38084. /**
  38085. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38086. */
  38087. static Canvas: Nullable<HTMLCanvasElement>;
  38088. private static _globalJoystickIndex;
  38089. private static vjCanvasContext;
  38090. private static vjCanvasWidth;
  38091. private static vjCanvasHeight;
  38092. private static halfWidth;
  38093. private _action;
  38094. private _axisTargetedByLeftAndRight;
  38095. private _axisTargetedByUpAndDown;
  38096. private _joystickSensibility;
  38097. private _inversedSensibility;
  38098. private _joystickPointerID;
  38099. private _joystickColor;
  38100. private _joystickPointerPos;
  38101. private _joystickPreviousPointerPos;
  38102. private _joystickPointerStartPos;
  38103. private _deltaJoystickVector;
  38104. private _leftJoystick;
  38105. private _touches;
  38106. private _onPointerDownHandlerRef;
  38107. private _onPointerMoveHandlerRef;
  38108. private _onPointerUpHandlerRef;
  38109. private _onResize;
  38110. /**
  38111. * Creates a new virtual joystick
  38112. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38113. */
  38114. constructor(leftJoystick?: boolean);
  38115. /**
  38116. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38117. * @param newJoystickSensibility defines the new sensibility
  38118. */
  38119. setJoystickSensibility(newJoystickSensibility: number): void;
  38120. private _onPointerDown;
  38121. private _onPointerMove;
  38122. private _onPointerUp;
  38123. /**
  38124. * Change the color of the virtual joystick
  38125. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38126. */
  38127. setJoystickColor(newColor: string): void;
  38128. /**
  38129. * Defines a callback to call when the joystick is touched
  38130. * @param action defines the callback
  38131. */
  38132. setActionOnTouch(action: () => any): void;
  38133. /**
  38134. * Defines which axis you'd like to control for left & right
  38135. * @param axis defines the axis to use
  38136. */
  38137. setAxisForLeftRight(axis: JoystickAxis): void;
  38138. /**
  38139. * Defines which axis you'd like to control for up & down
  38140. * @param axis defines the axis to use
  38141. */
  38142. setAxisForUpDown(axis: JoystickAxis): void;
  38143. private _drawVirtualJoystick;
  38144. /**
  38145. * Release internal HTML canvas
  38146. */
  38147. releaseCanvas(): void;
  38148. }
  38149. }
  38150. declare module BABYLON {
  38151. interface FreeCameraInputsManager {
  38152. /**
  38153. * Add virtual joystick input support to the input manager.
  38154. * @returns the current input manager
  38155. */
  38156. addVirtualJoystick(): FreeCameraInputsManager;
  38157. }
  38158. /**
  38159. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38161. */
  38162. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38163. /**
  38164. * Defines the camera the input is attached to.
  38165. */
  38166. camera: FreeCamera;
  38167. private _leftjoystick;
  38168. private _rightjoystick;
  38169. /**
  38170. * Gets the left stick of the virtual joystick.
  38171. * @returns The virtual Joystick
  38172. */
  38173. getLeftJoystick(): VirtualJoystick;
  38174. /**
  38175. * Gets the right stick of the virtual joystick.
  38176. * @returns The virtual Joystick
  38177. */
  38178. getRightJoystick(): VirtualJoystick;
  38179. /**
  38180. * Update the current camera state depending on the inputs that have been used this frame.
  38181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38182. */
  38183. checkInputs(): void;
  38184. /**
  38185. * Attach the input controls to a specific dom element to get the input from.
  38186. * @param element Defines the element the controls should be listened from
  38187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38188. */
  38189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38190. /**
  38191. * Detach the current controls from the specified dom element.
  38192. * @param element Defines the element to stop listening the inputs from
  38193. */
  38194. detachControl(element: Nullable<HTMLElement>): void;
  38195. /**
  38196. * Gets the class name of the current intput.
  38197. * @returns the class name
  38198. */
  38199. getClassName(): string;
  38200. /**
  38201. * Get the friendly name associated with the input class.
  38202. * @returns the input friendly name
  38203. */
  38204. getSimpleName(): string;
  38205. }
  38206. }
  38207. declare module BABYLON {
  38208. /**
  38209. * This represents a FPS type of camera controlled by touch.
  38210. * This is like a universal camera minus the Gamepad controls.
  38211. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38212. */
  38213. export class TouchCamera extends FreeCamera {
  38214. /**
  38215. * Defines the touch sensibility for rotation.
  38216. * The higher the faster.
  38217. */
  38218. touchAngularSensibility: number;
  38219. /**
  38220. * Defines the touch sensibility for move.
  38221. * The higher the faster.
  38222. */
  38223. touchMoveSensibility: number;
  38224. /**
  38225. * Instantiates a new touch camera.
  38226. * This represents a FPS type of camera controlled by touch.
  38227. * This is like a universal camera minus the Gamepad controls.
  38228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38229. * @param name Define the name of the camera in the scene
  38230. * @param position Define the start position of the camera in the scene
  38231. * @param scene Define the scene the camera belongs to
  38232. */
  38233. constructor(name: string, position: Vector3, scene: Scene);
  38234. /**
  38235. * Gets the current object class name.
  38236. * @return the class name
  38237. */
  38238. getClassName(): string;
  38239. /** @hidden */
  38240. _setupInputs(): void;
  38241. }
  38242. }
  38243. declare module BABYLON {
  38244. /**
  38245. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38246. * being tilted forward or back and left or right.
  38247. */
  38248. export class DeviceOrientationCamera extends FreeCamera {
  38249. private _initialQuaternion;
  38250. private _quaternionCache;
  38251. private _tmpDragQuaternion;
  38252. private _disablePointerInputWhenUsingDeviceOrientation;
  38253. /**
  38254. * Creates a new device orientation camera
  38255. * @param name The name of the camera
  38256. * @param position The start position camera
  38257. * @param scene The scene the camera belongs to
  38258. */
  38259. constructor(name: string, position: Vector3, scene: Scene);
  38260. /**
  38261. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38262. */
  38263. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38264. private _dragFactor;
  38265. /**
  38266. * Enabled turning on the y axis when the orientation sensor is active
  38267. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38268. */
  38269. enableHorizontalDragging(dragFactor?: number): void;
  38270. /**
  38271. * Gets the current instance class name ("DeviceOrientationCamera").
  38272. * This helps avoiding instanceof at run time.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. /**
  38277. * @hidden
  38278. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38279. */
  38280. _checkInputs(): void;
  38281. /**
  38282. * Reset the camera to its default orientation on the specified axis only.
  38283. * @param axis The axis to reset
  38284. */
  38285. resetToCurrentRotation(axis?: Axis): void;
  38286. }
  38287. }
  38288. declare module BABYLON {
  38289. /**
  38290. * Defines supported buttons for XBox360 compatible gamepads
  38291. */
  38292. export enum Xbox360Button {
  38293. /** A */
  38294. A = 0,
  38295. /** B */
  38296. B = 1,
  38297. /** X */
  38298. X = 2,
  38299. /** Y */
  38300. Y = 3,
  38301. /** Start */
  38302. Start = 4,
  38303. /** Back */
  38304. Back = 5,
  38305. /** Left button */
  38306. LB = 6,
  38307. /** Right button */
  38308. RB = 7,
  38309. /** Left stick */
  38310. LeftStick = 8,
  38311. /** Right stick */
  38312. RightStick = 9
  38313. }
  38314. /** Defines values for XBox360 DPad */
  38315. export enum Xbox360Dpad {
  38316. /** Up */
  38317. Up = 0,
  38318. /** Down */
  38319. Down = 1,
  38320. /** Left */
  38321. Left = 2,
  38322. /** Right */
  38323. Right = 3
  38324. }
  38325. /**
  38326. * Defines a XBox360 gamepad
  38327. */
  38328. export class Xbox360Pad extends Gamepad {
  38329. private _leftTrigger;
  38330. private _rightTrigger;
  38331. private _onlefttriggerchanged;
  38332. private _onrighttriggerchanged;
  38333. private _onbuttondown;
  38334. private _onbuttonup;
  38335. private _ondpaddown;
  38336. private _ondpadup;
  38337. /** Observable raised when a button is pressed */
  38338. onButtonDownObservable: Observable<Xbox360Button>;
  38339. /** Observable raised when a button is released */
  38340. onButtonUpObservable: Observable<Xbox360Button>;
  38341. /** Observable raised when a pad is pressed */
  38342. onPadDownObservable: Observable<Xbox360Dpad>;
  38343. /** Observable raised when a pad is released */
  38344. onPadUpObservable: Observable<Xbox360Dpad>;
  38345. private _buttonA;
  38346. private _buttonB;
  38347. private _buttonX;
  38348. private _buttonY;
  38349. private _buttonBack;
  38350. private _buttonStart;
  38351. private _buttonLB;
  38352. private _buttonRB;
  38353. private _buttonLeftStick;
  38354. private _buttonRightStick;
  38355. private _dPadUp;
  38356. private _dPadDown;
  38357. private _dPadLeft;
  38358. private _dPadRight;
  38359. private _isXboxOnePad;
  38360. /**
  38361. * Creates a new XBox360 gamepad object
  38362. * @param id defines the id of this gamepad
  38363. * @param index defines its index
  38364. * @param gamepad defines the internal HTML gamepad object
  38365. * @param xboxOne defines if it is a XBox One gamepad
  38366. */
  38367. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38368. /**
  38369. * Defines the callback to call when left trigger is pressed
  38370. * @param callback defines the callback to use
  38371. */
  38372. onlefttriggerchanged(callback: (value: number) => void): void;
  38373. /**
  38374. * Defines the callback to call when right trigger is pressed
  38375. * @param callback defines the callback to use
  38376. */
  38377. onrighttriggerchanged(callback: (value: number) => void): void;
  38378. /**
  38379. * Gets the left trigger value
  38380. */
  38381. /**
  38382. * Sets the left trigger value
  38383. */
  38384. leftTrigger: number;
  38385. /**
  38386. * Gets the right trigger value
  38387. */
  38388. /**
  38389. * Sets the right trigger value
  38390. */
  38391. rightTrigger: number;
  38392. /**
  38393. * Defines the callback to call when a button is pressed
  38394. * @param callback defines the callback to use
  38395. */
  38396. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38397. /**
  38398. * Defines the callback to call when a button is released
  38399. * @param callback defines the callback to use
  38400. */
  38401. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38402. /**
  38403. * Defines the callback to call when a pad is pressed
  38404. * @param callback defines the callback to use
  38405. */
  38406. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38407. /**
  38408. * Defines the callback to call when a pad is released
  38409. * @param callback defines the callback to use
  38410. */
  38411. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38412. private _setButtonValue;
  38413. private _setDPadValue;
  38414. /**
  38415. * Gets the value of the `A` button
  38416. */
  38417. /**
  38418. * Sets the value of the `A` button
  38419. */
  38420. buttonA: number;
  38421. /**
  38422. * Gets the value of the `B` button
  38423. */
  38424. /**
  38425. * Sets the value of the `B` button
  38426. */
  38427. buttonB: number;
  38428. /**
  38429. * Gets the value of the `X` button
  38430. */
  38431. /**
  38432. * Sets the value of the `X` button
  38433. */
  38434. buttonX: number;
  38435. /**
  38436. * Gets the value of the `Y` button
  38437. */
  38438. /**
  38439. * Sets the value of the `Y` button
  38440. */
  38441. buttonY: number;
  38442. /**
  38443. * Gets the value of the `Start` button
  38444. */
  38445. /**
  38446. * Sets the value of the `Start` button
  38447. */
  38448. buttonStart: number;
  38449. /**
  38450. * Gets the value of the `Back` button
  38451. */
  38452. /**
  38453. * Sets the value of the `Back` button
  38454. */
  38455. buttonBack: number;
  38456. /**
  38457. * Gets the value of the `Left` button
  38458. */
  38459. /**
  38460. * Sets the value of the `Left` button
  38461. */
  38462. buttonLB: number;
  38463. /**
  38464. * Gets the value of the `Right` button
  38465. */
  38466. /**
  38467. * Sets the value of the `Right` button
  38468. */
  38469. buttonRB: number;
  38470. /**
  38471. * Gets the value of the Left joystick
  38472. */
  38473. /**
  38474. * Sets the value of the Left joystick
  38475. */
  38476. buttonLeftStick: number;
  38477. /**
  38478. * Gets the value of the Right joystick
  38479. */
  38480. /**
  38481. * Sets the value of the Right joystick
  38482. */
  38483. buttonRightStick: number;
  38484. /**
  38485. * Gets the value of D-pad up
  38486. */
  38487. /**
  38488. * Sets the value of D-pad up
  38489. */
  38490. dPadUp: number;
  38491. /**
  38492. * Gets the value of D-pad down
  38493. */
  38494. /**
  38495. * Sets the value of D-pad down
  38496. */
  38497. dPadDown: number;
  38498. /**
  38499. * Gets the value of D-pad left
  38500. */
  38501. /**
  38502. * Sets the value of D-pad left
  38503. */
  38504. dPadLeft: number;
  38505. /**
  38506. * Gets the value of D-pad right
  38507. */
  38508. /**
  38509. * Sets the value of D-pad right
  38510. */
  38511. dPadRight: number;
  38512. /**
  38513. * Force the gamepad to synchronize with device values
  38514. */
  38515. update(): void;
  38516. /**
  38517. * Disposes the gamepad
  38518. */
  38519. dispose(): void;
  38520. }
  38521. }
  38522. declare module BABYLON {
  38523. /**
  38524. * Defines supported buttons for DualShock compatible gamepads
  38525. */
  38526. export enum DualShockButton {
  38527. /** Cross */
  38528. Cross = 0,
  38529. /** Circle */
  38530. Circle = 1,
  38531. /** Square */
  38532. Square = 2,
  38533. /** Triangle */
  38534. Triangle = 3,
  38535. /** Options */
  38536. Options = 4,
  38537. /** Share */
  38538. Share = 5,
  38539. /** L1 */
  38540. L1 = 6,
  38541. /** R1 */
  38542. R1 = 7,
  38543. /** Left stick */
  38544. LeftStick = 8,
  38545. /** Right stick */
  38546. RightStick = 9
  38547. }
  38548. /** Defines values for DualShock DPad */
  38549. export enum DualShockDpad {
  38550. /** Up */
  38551. Up = 0,
  38552. /** Down */
  38553. Down = 1,
  38554. /** Left */
  38555. Left = 2,
  38556. /** Right */
  38557. Right = 3
  38558. }
  38559. /**
  38560. * Defines a DualShock gamepad
  38561. */
  38562. export class DualShockPad extends Gamepad {
  38563. private _leftTrigger;
  38564. private _rightTrigger;
  38565. private _onlefttriggerchanged;
  38566. private _onrighttriggerchanged;
  38567. private _onbuttondown;
  38568. private _onbuttonup;
  38569. private _ondpaddown;
  38570. private _ondpadup;
  38571. /** Observable raised when a button is pressed */
  38572. onButtonDownObservable: Observable<DualShockButton>;
  38573. /** Observable raised when a button is released */
  38574. onButtonUpObservable: Observable<DualShockButton>;
  38575. /** Observable raised when a pad is pressed */
  38576. onPadDownObservable: Observable<DualShockDpad>;
  38577. /** Observable raised when a pad is released */
  38578. onPadUpObservable: Observable<DualShockDpad>;
  38579. private _buttonCross;
  38580. private _buttonCircle;
  38581. private _buttonSquare;
  38582. private _buttonTriangle;
  38583. private _buttonShare;
  38584. private _buttonOptions;
  38585. private _buttonL1;
  38586. private _buttonR1;
  38587. private _buttonLeftStick;
  38588. private _buttonRightStick;
  38589. private _dPadUp;
  38590. private _dPadDown;
  38591. private _dPadLeft;
  38592. private _dPadRight;
  38593. /**
  38594. * Creates a new DualShock gamepad object
  38595. * @param id defines the id of this gamepad
  38596. * @param index defines its index
  38597. * @param gamepad defines the internal HTML gamepad object
  38598. */
  38599. constructor(id: string, index: number, gamepad: any);
  38600. /**
  38601. * Defines the callback to call when left trigger is pressed
  38602. * @param callback defines the callback to use
  38603. */
  38604. onlefttriggerchanged(callback: (value: number) => void): void;
  38605. /**
  38606. * Defines the callback to call when right trigger is pressed
  38607. * @param callback defines the callback to use
  38608. */
  38609. onrighttriggerchanged(callback: (value: number) => void): void;
  38610. /**
  38611. * Gets the left trigger value
  38612. */
  38613. /**
  38614. * Sets the left trigger value
  38615. */
  38616. leftTrigger: number;
  38617. /**
  38618. * Gets the right trigger value
  38619. */
  38620. /**
  38621. * Sets the right trigger value
  38622. */
  38623. rightTrigger: number;
  38624. /**
  38625. * Defines the callback to call when a button is pressed
  38626. * @param callback defines the callback to use
  38627. */
  38628. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38629. /**
  38630. * Defines the callback to call when a button is released
  38631. * @param callback defines the callback to use
  38632. */
  38633. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38634. /**
  38635. * Defines the callback to call when a pad is pressed
  38636. * @param callback defines the callback to use
  38637. */
  38638. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38639. /**
  38640. * Defines the callback to call when a pad is released
  38641. * @param callback defines the callback to use
  38642. */
  38643. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38644. private _setButtonValue;
  38645. private _setDPadValue;
  38646. /**
  38647. * Gets the value of the `Cross` button
  38648. */
  38649. /**
  38650. * Sets the value of the `Cross` button
  38651. */
  38652. buttonCross: number;
  38653. /**
  38654. * Gets the value of the `Circle` button
  38655. */
  38656. /**
  38657. * Sets the value of the `Circle` button
  38658. */
  38659. buttonCircle: number;
  38660. /**
  38661. * Gets the value of the `Square` button
  38662. */
  38663. /**
  38664. * Sets the value of the `Square` button
  38665. */
  38666. buttonSquare: number;
  38667. /**
  38668. * Gets the value of the `Triangle` button
  38669. */
  38670. /**
  38671. * Sets the value of the `Triangle` button
  38672. */
  38673. buttonTriangle: number;
  38674. /**
  38675. * Gets the value of the `Options` button
  38676. */
  38677. /**
  38678. * Sets the value of the `Options` button
  38679. */
  38680. buttonOptions: number;
  38681. /**
  38682. * Gets the value of the `Share` button
  38683. */
  38684. /**
  38685. * Sets the value of the `Share` button
  38686. */
  38687. buttonShare: number;
  38688. /**
  38689. * Gets the value of the `L1` button
  38690. */
  38691. /**
  38692. * Sets the value of the `L1` button
  38693. */
  38694. buttonL1: number;
  38695. /**
  38696. * Gets the value of the `R1` button
  38697. */
  38698. /**
  38699. * Sets the value of the `R1` button
  38700. */
  38701. buttonR1: number;
  38702. /**
  38703. * Gets the value of the Left joystick
  38704. */
  38705. /**
  38706. * Sets the value of the Left joystick
  38707. */
  38708. buttonLeftStick: number;
  38709. /**
  38710. * Gets the value of the Right joystick
  38711. */
  38712. /**
  38713. * Sets the value of the Right joystick
  38714. */
  38715. buttonRightStick: number;
  38716. /**
  38717. * Gets the value of D-pad up
  38718. */
  38719. /**
  38720. * Sets the value of D-pad up
  38721. */
  38722. dPadUp: number;
  38723. /**
  38724. * Gets the value of D-pad down
  38725. */
  38726. /**
  38727. * Sets the value of D-pad down
  38728. */
  38729. dPadDown: number;
  38730. /**
  38731. * Gets the value of D-pad left
  38732. */
  38733. /**
  38734. * Sets the value of D-pad left
  38735. */
  38736. dPadLeft: number;
  38737. /**
  38738. * Gets the value of D-pad right
  38739. */
  38740. /**
  38741. * Sets the value of D-pad right
  38742. */
  38743. dPadRight: number;
  38744. /**
  38745. * Force the gamepad to synchronize with device values
  38746. */
  38747. update(): void;
  38748. /**
  38749. * Disposes the gamepad
  38750. */
  38751. dispose(): void;
  38752. }
  38753. }
  38754. declare module BABYLON {
  38755. /**
  38756. * Manager for handling gamepads
  38757. */
  38758. export class GamepadManager {
  38759. private _scene?;
  38760. private _babylonGamepads;
  38761. private _oneGamepadConnected;
  38762. /** @hidden */
  38763. _isMonitoring: boolean;
  38764. private _gamepadEventSupported;
  38765. private _gamepadSupport;
  38766. /**
  38767. * observable to be triggered when the gamepad controller has been connected
  38768. */
  38769. onGamepadConnectedObservable: Observable<Gamepad>;
  38770. /**
  38771. * observable to be triggered when the gamepad controller has been disconnected
  38772. */
  38773. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38774. private _onGamepadConnectedEvent;
  38775. private _onGamepadDisconnectedEvent;
  38776. /**
  38777. * Initializes the gamepad manager
  38778. * @param _scene BabylonJS scene
  38779. */
  38780. constructor(_scene?: Scene | undefined);
  38781. /**
  38782. * The gamepads in the game pad manager
  38783. */
  38784. readonly gamepads: Gamepad[];
  38785. /**
  38786. * Get the gamepad controllers based on type
  38787. * @param type The type of gamepad controller
  38788. * @returns Nullable gamepad
  38789. */
  38790. getGamepadByType(type?: number): Nullable<Gamepad>;
  38791. /**
  38792. * Disposes the gamepad manager
  38793. */
  38794. dispose(): void;
  38795. private _addNewGamepad;
  38796. private _startMonitoringGamepads;
  38797. private _stopMonitoringGamepads;
  38798. /** @hidden */
  38799. _checkGamepadsStatus(): void;
  38800. private _updateGamepadObjects;
  38801. }
  38802. }
  38803. declare module BABYLON {
  38804. interface Scene {
  38805. /** @hidden */
  38806. _gamepadManager: Nullable<GamepadManager>;
  38807. /**
  38808. * Gets the gamepad manager associated with the scene
  38809. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38810. */
  38811. gamepadManager: GamepadManager;
  38812. }
  38813. /**
  38814. * Interface representing a free camera inputs manager
  38815. */
  38816. interface FreeCameraInputsManager {
  38817. /**
  38818. * Adds gamepad input support to the FreeCameraInputsManager.
  38819. * @returns the FreeCameraInputsManager
  38820. */
  38821. addGamepad(): FreeCameraInputsManager;
  38822. }
  38823. /**
  38824. * Interface representing an arc rotate camera inputs manager
  38825. */
  38826. interface ArcRotateCameraInputsManager {
  38827. /**
  38828. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38829. * @returns the camera inputs manager
  38830. */
  38831. addGamepad(): ArcRotateCameraInputsManager;
  38832. }
  38833. /**
  38834. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38835. */
  38836. export class GamepadSystemSceneComponent implements ISceneComponent {
  38837. /**
  38838. * The component name helpfull to identify the component in the list of scene components.
  38839. */
  38840. readonly name: string;
  38841. /**
  38842. * The scene the component belongs to.
  38843. */
  38844. scene: Scene;
  38845. /**
  38846. * Creates a new instance of the component for the given scene
  38847. * @param scene Defines the scene to register the component in
  38848. */
  38849. constructor(scene: Scene);
  38850. /**
  38851. * Registers the component in a given scene
  38852. */
  38853. register(): void;
  38854. /**
  38855. * Rebuilds the elements related to this component in case of
  38856. * context lost for instance.
  38857. */
  38858. rebuild(): void;
  38859. /**
  38860. * Disposes the component and the associated ressources
  38861. */
  38862. dispose(): void;
  38863. private _beforeCameraUpdate;
  38864. }
  38865. }
  38866. declare module BABYLON {
  38867. /**
  38868. * 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,
  38869. * which still works and will still be found in many Playgrounds.
  38870. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38871. */
  38872. export class UniversalCamera extends TouchCamera {
  38873. /**
  38874. * Defines the gamepad rotation sensiblity.
  38875. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38876. */
  38877. gamepadAngularSensibility: number;
  38878. /**
  38879. * Defines the gamepad move sensiblity.
  38880. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38881. */
  38882. gamepadMoveSensibility: number;
  38883. /**
  38884. * 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,
  38885. * which still works and will still be found in many Playgrounds.
  38886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38887. * @param name Define the name of the camera in the scene
  38888. * @param position Define the start position of the camera in the scene
  38889. * @param scene Define the scene the camera belongs to
  38890. */
  38891. constructor(name: string, position: Vector3, scene: Scene);
  38892. /**
  38893. * Gets the current object class name.
  38894. * @return the class name
  38895. */
  38896. getClassName(): string;
  38897. }
  38898. }
  38899. declare module BABYLON {
  38900. /**
  38901. * This represents a FPS type of camera. This is only here for back compat purpose.
  38902. * Please use the UniversalCamera instead as both are identical.
  38903. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38904. */
  38905. export class GamepadCamera extends UniversalCamera {
  38906. /**
  38907. * Instantiates a new Gamepad Camera
  38908. * This represents a FPS type of camera. This is only here for back compat purpose.
  38909. * Please use the UniversalCamera instead as both are identical.
  38910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38911. * @param name Define the name of the camera in the scene
  38912. * @param position Define the start position of the camera in the scene
  38913. * @param scene Define the scene the camera belongs to
  38914. */
  38915. constructor(name: string, position: Vector3, scene: Scene);
  38916. /**
  38917. * Gets the current object class name.
  38918. * @return the class name
  38919. */
  38920. getClassName(): string;
  38921. }
  38922. }
  38923. declare module BABYLON {
  38924. /** @hidden */
  38925. export var passPixelShader: {
  38926. name: string;
  38927. shader: string;
  38928. };
  38929. }
  38930. declare module BABYLON {
  38931. /** @hidden */
  38932. export var passCubePixelShader: {
  38933. name: string;
  38934. shader: string;
  38935. };
  38936. }
  38937. declare module BABYLON {
  38938. /**
  38939. * PassPostProcess which produces an output the same as it's input
  38940. */
  38941. export class PassPostProcess extends PostProcess {
  38942. /**
  38943. * Creates the PassPostProcess
  38944. * @param name The name of the effect.
  38945. * @param options The required width/height ratio to downsize to before computing the render pass.
  38946. * @param camera The camera to apply the render pass to.
  38947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38948. * @param engine The engine which the post process will be applied. (default: current engine)
  38949. * @param reusable If the post process can be reused on the same frame. (default: false)
  38950. * @param textureType The type of texture to be used when performing the post processing.
  38951. * @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)
  38952. */
  38953. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38954. }
  38955. /**
  38956. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38957. */
  38958. export class PassCubePostProcess extends PostProcess {
  38959. private _face;
  38960. /**
  38961. * Gets or sets the cube face to display.
  38962. * * 0 is +X
  38963. * * 1 is -X
  38964. * * 2 is +Y
  38965. * * 3 is -Y
  38966. * * 4 is +Z
  38967. * * 5 is -Z
  38968. */
  38969. face: number;
  38970. /**
  38971. * Creates the PassCubePostProcess
  38972. * @param name The name of the effect.
  38973. * @param options The required width/height ratio to downsize to before computing the render pass.
  38974. * @param camera The camera to apply the render pass to.
  38975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38976. * @param engine The engine which the post process will be applied. (default: current engine)
  38977. * @param reusable If the post process can be reused on the same frame. (default: false)
  38978. * @param textureType The type of texture to be used when performing the post processing.
  38979. * @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)
  38980. */
  38981. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38982. }
  38983. }
  38984. declare module BABYLON {
  38985. /** @hidden */
  38986. export var anaglyphPixelShader: {
  38987. name: string;
  38988. shader: string;
  38989. };
  38990. }
  38991. declare module BABYLON {
  38992. /**
  38993. * Postprocess used to generate anaglyphic rendering
  38994. */
  38995. export class AnaglyphPostProcess extends PostProcess {
  38996. private _passedProcess;
  38997. /**
  38998. * Creates a new AnaglyphPostProcess
  38999. * @param name defines postprocess name
  39000. * @param options defines creation options or target ratio scale
  39001. * @param rigCameras defines cameras using this postprocess
  39002. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39003. * @param engine defines hosting engine
  39004. * @param reusable defines if the postprocess will be reused multiple times per frame
  39005. */
  39006. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39007. }
  39008. }
  39009. declare module BABYLON {
  39010. /**
  39011. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39012. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39013. */
  39014. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39015. /**
  39016. * Creates a new AnaglyphArcRotateCamera
  39017. * @param name defines camera name
  39018. * @param alpha defines alpha angle (in radians)
  39019. * @param beta defines beta angle (in radians)
  39020. * @param radius defines radius
  39021. * @param target defines camera target
  39022. * @param interaxialDistance defines distance between each color axis
  39023. * @param scene defines the hosting scene
  39024. */
  39025. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39026. /**
  39027. * Gets camera class name
  39028. * @returns AnaglyphArcRotateCamera
  39029. */
  39030. getClassName(): string;
  39031. }
  39032. }
  39033. declare module BABYLON {
  39034. /**
  39035. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39036. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39037. */
  39038. export class AnaglyphFreeCamera extends FreeCamera {
  39039. /**
  39040. * Creates a new AnaglyphFreeCamera
  39041. * @param name defines camera name
  39042. * @param position defines initial position
  39043. * @param interaxialDistance defines distance between each color axis
  39044. * @param scene defines the hosting scene
  39045. */
  39046. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39047. /**
  39048. * Gets camera class name
  39049. * @returns AnaglyphFreeCamera
  39050. */
  39051. getClassName(): string;
  39052. }
  39053. }
  39054. declare module BABYLON {
  39055. /**
  39056. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39057. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39058. */
  39059. export class AnaglyphGamepadCamera extends GamepadCamera {
  39060. /**
  39061. * Creates a new AnaglyphGamepadCamera
  39062. * @param name defines camera name
  39063. * @param position defines initial position
  39064. * @param interaxialDistance defines distance between each color axis
  39065. * @param scene defines the hosting scene
  39066. */
  39067. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39068. /**
  39069. * Gets camera class name
  39070. * @returns AnaglyphGamepadCamera
  39071. */
  39072. getClassName(): string;
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. /**
  39077. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39078. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39079. */
  39080. export class AnaglyphUniversalCamera extends UniversalCamera {
  39081. /**
  39082. * Creates a new AnaglyphUniversalCamera
  39083. * @param name defines camera name
  39084. * @param position defines initial position
  39085. * @param interaxialDistance defines distance between each color axis
  39086. * @param scene defines the hosting scene
  39087. */
  39088. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39089. /**
  39090. * Gets camera class name
  39091. * @returns AnaglyphUniversalCamera
  39092. */
  39093. getClassName(): string;
  39094. }
  39095. }
  39096. declare module BABYLON {
  39097. /** @hidden */
  39098. export var stereoscopicInterlacePixelShader: {
  39099. name: string;
  39100. shader: string;
  39101. };
  39102. }
  39103. declare module BABYLON {
  39104. /**
  39105. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39106. */
  39107. export class StereoscopicInterlacePostProcess extends PostProcess {
  39108. private _stepSize;
  39109. private _passedProcess;
  39110. /**
  39111. * Initializes a StereoscopicInterlacePostProcess
  39112. * @param name The name of the effect.
  39113. * @param rigCameras The rig cameras to be appled to the post process
  39114. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39116. * @param engine The engine which the post process will be applied. (default: current engine)
  39117. * @param reusable If the post process can be reused on the same frame. (default: false)
  39118. */
  39119. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39120. }
  39121. }
  39122. declare module BABYLON {
  39123. /**
  39124. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39125. * @see http://doc.babylonjs.com/features/cameras
  39126. */
  39127. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39128. /**
  39129. * Creates a new StereoscopicArcRotateCamera
  39130. * @param name defines camera name
  39131. * @param alpha defines alpha angle (in radians)
  39132. * @param beta defines beta angle (in radians)
  39133. * @param radius defines radius
  39134. * @param target defines camera target
  39135. * @param interaxialDistance defines distance between each color axis
  39136. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39137. * @param scene defines the hosting scene
  39138. */
  39139. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39140. /**
  39141. * Gets camera class name
  39142. * @returns StereoscopicArcRotateCamera
  39143. */
  39144. getClassName(): string;
  39145. }
  39146. }
  39147. declare module BABYLON {
  39148. /**
  39149. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39150. * @see http://doc.babylonjs.com/features/cameras
  39151. */
  39152. export class StereoscopicFreeCamera extends FreeCamera {
  39153. /**
  39154. * Creates a new StereoscopicFreeCamera
  39155. * @param name defines camera name
  39156. * @param position defines initial position
  39157. * @param interaxialDistance defines distance between each color axis
  39158. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39159. * @param scene defines the hosting scene
  39160. */
  39161. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39162. /**
  39163. * Gets camera class name
  39164. * @returns StereoscopicFreeCamera
  39165. */
  39166. getClassName(): string;
  39167. }
  39168. }
  39169. declare module BABYLON {
  39170. /**
  39171. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39172. * @see http://doc.babylonjs.com/features/cameras
  39173. */
  39174. export class StereoscopicGamepadCamera extends GamepadCamera {
  39175. /**
  39176. * Creates a new StereoscopicGamepadCamera
  39177. * @param name defines camera name
  39178. * @param position defines initial position
  39179. * @param interaxialDistance defines distance between each color axis
  39180. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39181. * @param scene defines the hosting scene
  39182. */
  39183. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39184. /**
  39185. * Gets camera class name
  39186. * @returns StereoscopicGamepadCamera
  39187. */
  39188. getClassName(): string;
  39189. }
  39190. }
  39191. declare module BABYLON {
  39192. /**
  39193. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39194. * @see http://doc.babylonjs.com/features/cameras
  39195. */
  39196. export class StereoscopicUniversalCamera extends UniversalCamera {
  39197. /**
  39198. * Creates a new StereoscopicUniversalCamera
  39199. * @param name defines camera name
  39200. * @param position defines initial position
  39201. * @param interaxialDistance defines distance between each color axis
  39202. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39203. * @param scene defines the hosting scene
  39204. */
  39205. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39206. /**
  39207. * Gets camera class name
  39208. * @returns StereoscopicUniversalCamera
  39209. */
  39210. getClassName(): string;
  39211. }
  39212. }
  39213. declare module BABYLON {
  39214. /**
  39215. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39216. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39217. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39218. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39219. */
  39220. export class VirtualJoysticksCamera extends FreeCamera {
  39221. /**
  39222. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39223. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39224. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39225. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39226. * @param name Define the name of the camera in the scene
  39227. * @param position Define the start position of the camera in the scene
  39228. * @param scene Define the scene the camera belongs to
  39229. */
  39230. constructor(name: string, position: Vector3, scene: Scene);
  39231. /**
  39232. * Gets the current object class name.
  39233. * @return the class name
  39234. */
  39235. getClassName(): string;
  39236. }
  39237. }
  39238. declare module BABYLON {
  39239. /**
  39240. * This represents all the required metrics to create a VR camera.
  39241. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39242. */
  39243. export class VRCameraMetrics {
  39244. /**
  39245. * Define the horizontal resolution off the screen.
  39246. */
  39247. hResolution: number;
  39248. /**
  39249. * Define the vertical resolution off the screen.
  39250. */
  39251. vResolution: number;
  39252. /**
  39253. * Define the horizontal screen size.
  39254. */
  39255. hScreenSize: number;
  39256. /**
  39257. * Define the vertical screen size.
  39258. */
  39259. vScreenSize: number;
  39260. /**
  39261. * Define the vertical screen center position.
  39262. */
  39263. vScreenCenter: number;
  39264. /**
  39265. * Define the distance of the eyes to the screen.
  39266. */
  39267. eyeToScreenDistance: number;
  39268. /**
  39269. * Define the distance between both lenses
  39270. */
  39271. lensSeparationDistance: number;
  39272. /**
  39273. * Define the distance between both viewer's eyes.
  39274. */
  39275. interpupillaryDistance: number;
  39276. /**
  39277. * Define the distortion factor of the VR postprocess.
  39278. * Please, touch with care.
  39279. */
  39280. distortionK: number[];
  39281. /**
  39282. * Define the chromatic aberration correction factors for the VR post process.
  39283. */
  39284. chromaAbCorrection: number[];
  39285. /**
  39286. * Define the scale factor of the post process.
  39287. * The smaller the better but the slower.
  39288. */
  39289. postProcessScaleFactor: number;
  39290. /**
  39291. * Define an offset for the lens center.
  39292. */
  39293. lensCenterOffset: number;
  39294. /**
  39295. * Define if the current vr camera should compensate the distortion of the lense or not.
  39296. */
  39297. compensateDistortion: boolean;
  39298. /**
  39299. * Defines if multiview should be enabled when rendering (Default: false)
  39300. */
  39301. multiviewEnabled: boolean;
  39302. /**
  39303. * Gets the rendering aspect ratio based on the provided resolutions.
  39304. */
  39305. readonly aspectRatio: number;
  39306. /**
  39307. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39308. */
  39309. readonly aspectRatioFov: number;
  39310. /**
  39311. * @hidden
  39312. */
  39313. readonly leftHMatrix: Matrix;
  39314. /**
  39315. * @hidden
  39316. */
  39317. readonly rightHMatrix: Matrix;
  39318. /**
  39319. * @hidden
  39320. */
  39321. readonly leftPreViewMatrix: Matrix;
  39322. /**
  39323. * @hidden
  39324. */
  39325. readonly rightPreViewMatrix: Matrix;
  39326. /**
  39327. * Get the default VRMetrics based on the most generic setup.
  39328. * @returns the default vr metrics
  39329. */
  39330. static GetDefault(): VRCameraMetrics;
  39331. }
  39332. }
  39333. declare module BABYLON {
  39334. /** @hidden */
  39335. export var vrDistortionCorrectionPixelShader: {
  39336. name: string;
  39337. shader: string;
  39338. };
  39339. }
  39340. declare module BABYLON {
  39341. /**
  39342. * VRDistortionCorrectionPostProcess used for mobile VR
  39343. */
  39344. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39345. private _isRightEye;
  39346. private _distortionFactors;
  39347. private _postProcessScaleFactor;
  39348. private _lensCenterOffset;
  39349. private _scaleIn;
  39350. private _scaleFactor;
  39351. private _lensCenter;
  39352. /**
  39353. * Initializes the VRDistortionCorrectionPostProcess
  39354. * @param name The name of the effect.
  39355. * @param camera The camera to apply the render pass to.
  39356. * @param isRightEye If this is for the right eye distortion
  39357. * @param vrMetrics All the required metrics for the VR camera
  39358. */
  39359. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39360. }
  39361. }
  39362. declare module BABYLON {
  39363. /**
  39364. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39365. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39366. */
  39367. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39368. /**
  39369. * Creates a new VRDeviceOrientationArcRotateCamera
  39370. * @param name defines camera name
  39371. * @param alpha defines the camera rotation along the logitudinal axis
  39372. * @param beta defines the camera rotation along the latitudinal axis
  39373. * @param radius defines the camera distance from its target
  39374. * @param target defines the camera target
  39375. * @param scene defines the scene the camera belongs to
  39376. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39377. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39378. */
  39379. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39380. /**
  39381. * Gets camera class name
  39382. * @returns VRDeviceOrientationArcRotateCamera
  39383. */
  39384. getClassName(): string;
  39385. }
  39386. }
  39387. declare module BABYLON {
  39388. /**
  39389. * Camera used to simulate VR rendering (based on FreeCamera)
  39390. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39391. */
  39392. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39393. /**
  39394. * Creates a new VRDeviceOrientationFreeCamera
  39395. * @param name defines camera name
  39396. * @param position defines the start position of the camera
  39397. * @param scene defines the scene the camera belongs to
  39398. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39399. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39400. */
  39401. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39402. /**
  39403. * Gets camera class name
  39404. * @returns VRDeviceOrientationFreeCamera
  39405. */
  39406. getClassName(): string;
  39407. }
  39408. }
  39409. declare module BABYLON {
  39410. /**
  39411. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39412. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39413. */
  39414. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39415. /**
  39416. * Creates a new VRDeviceOrientationGamepadCamera
  39417. * @param name defines camera name
  39418. * @param position defines the start position of the camera
  39419. * @param scene defines the scene the camera belongs to
  39420. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39421. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39422. */
  39423. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39424. /**
  39425. * Gets camera class name
  39426. * @returns VRDeviceOrientationGamepadCamera
  39427. */
  39428. getClassName(): string;
  39429. }
  39430. }
  39431. declare module BABYLON {
  39432. /**
  39433. * Base class of materials working in push mode in babylon JS
  39434. * @hidden
  39435. */
  39436. export class PushMaterial extends Material {
  39437. protected _activeEffect: Effect;
  39438. protected _normalMatrix: Matrix;
  39439. /**
  39440. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39441. * This means that the material can keep using a previous shader while a new one is being compiled.
  39442. * This is mostly used when shader parallel compilation is supported (true by default)
  39443. */
  39444. allowShaderHotSwapping: boolean;
  39445. constructor(name: string, scene: Scene);
  39446. getEffect(): Effect;
  39447. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39448. /**
  39449. * Binds the given world matrix to the active effect
  39450. *
  39451. * @param world the matrix to bind
  39452. */
  39453. bindOnlyWorldMatrix(world: Matrix): void;
  39454. /**
  39455. * Binds the given normal matrix to the active effect
  39456. *
  39457. * @param normalMatrix the matrix to bind
  39458. */
  39459. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39460. bind(world: Matrix, mesh?: Mesh): void;
  39461. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39462. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39463. }
  39464. }
  39465. declare module BABYLON {
  39466. /**
  39467. * This groups all the flags used to control the materials channel.
  39468. */
  39469. export class MaterialFlags {
  39470. private static _DiffuseTextureEnabled;
  39471. /**
  39472. * Are diffuse textures enabled in the application.
  39473. */
  39474. static DiffuseTextureEnabled: boolean;
  39475. private static _AmbientTextureEnabled;
  39476. /**
  39477. * Are ambient textures enabled in the application.
  39478. */
  39479. static AmbientTextureEnabled: boolean;
  39480. private static _OpacityTextureEnabled;
  39481. /**
  39482. * Are opacity textures enabled in the application.
  39483. */
  39484. static OpacityTextureEnabled: boolean;
  39485. private static _ReflectionTextureEnabled;
  39486. /**
  39487. * Are reflection textures enabled in the application.
  39488. */
  39489. static ReflectionTextureEnabled: boolean;
  39490. private static _EmissiveTextureEnabled;
  39491. /**
  39492. * Are emissive textures enabled in the application.
  39493. */
  39494. static EmissiveTextureEnabled: boolean;
  39495. private static _SpecularTextureEnabled;
  39496. /**
  39497. * Are specular textures enabled in the application.
  39498. */
  39499. static SpecularTextureEnabled: boolean;
  39500. private static _BumpTextureEnabled;
  39501. /**
  39502. * Are bump textures enabled in the application.
  39503. */
  39504. static BumpTextureEnabled: boolean;
  39505. private static _LightmapTextureEnabled;
  39506. /**
  39507. * Are lightmap textures enabled in the application.
  39508. */
  39509. static LightmapTextureEnabled: boolean;
  39510. private static _RefractionTextureEnabled;
  39511. /**
  39512. * Are refraction textures enabled in the application.
  39513. */
  39514. static RefractionTextureEnabled: boolean;
  39515. private static _ColorGradingTextureEnabled;
  39516. /**
  39517. * Are color grading textures enabled in the application.
  39518. */
  39519. static ColorGradingTextureEnabled: boolean;
  39520. private static _FresnelEnabled;
  39521. /**
  39522. * Are fresnels enabled in the application.
  39523. */
  39524. static FresnelEnabled: boolean;
  39525. private static _ClearCoatTextureEnabled;
  39526. /**
  39527. * Are clear coat textures enabled in the application.
  39528. */
  39529. static ClearCoatTextureEnabled: boolean;
  39530. private static _ClearCoatBumpTextureEnabled;
  39531. /**
  39532. * Are clear coat bump textures enabled in the application.
  39533. */
  39534. static ClearCoatBumpTextureEnabled: boolean;
  39535. private static _ClearCoatTintTextureEnabled;
  39536. /**
  39537. * Are clear coat tint textures enabled in the application.
  39538. */
  39539. static ClearCoatTintTextureEnabled: boolean;
  39540. private static _SheenTextureEnabled;
  39541. /**
  39542. * Are sheen textures enabled in the application.
  39543. */
  39544. static SheenTextureEnabled: boolean;
  39545. private static _AnisotropicTextureEnabled;
  39546. /**
  39547. * Are anisotropic textures enabled in the application.
  39548. */
  39549. static AnisotropicTextureEnabled: boolean;
  39550. private static _ThicknessTextureEnabled;
  39551. /**
  39552. * Are thickness textures enabled in the application.
  39553. */
  39554. static ThicknessTextureEnabled: boolean;
  39555. }
  39556. }
  39557. declare module BABYLON {
  39558. /** @hidden */
  39559. export var defaultFragmentDeclaration: {
  39560. name: string;
  39561. shader: string;
  39562. };
  39563. }
  39564. declare module BABYLON {
  39565. /** @hidden */
  39566. export var defaultUboDeclaration: {
  39567. name: string;
  39568. shader: string;
  39569. };
  39570. }
  39571. declare module BABYLON {
  39572. /** @hidden */
  39573. export var lightFragmentDeclaration: {
  39574. name: string;
  39575. shader: string;
  39576. };
  39577. }
  39578. declare module BABYLON {
  39579. /** @hidden */
  39580. export var lightUboDeclaration: {
  39581. name: string;
  39582. shader: string;
  39583. };
  39584. }
  39585. declare module BABYLON {
  39586. /** @hidden */
  39587. export var lightsFragmentFunctions: {
  39588. name: string;
  39589. shader: string;
  39590. };
  39591. }
  39592. declare module BABYLON {
  39593. /** @hidden */
  39594. export var shadowsFragmentFunctions: {
  39595. name: string;
  39596. shader: string;
  39597. };
  39598. }
  39599. declare module BABYLON {
  39600. /** @hidden */
  39601. export var fresnelFunction: {
  39602. name: string;
  39603. shader: string;
  39604. };
  39605. }
  39606. declare module BABYLON {
  39607. /** @hidden */
  39608. export var reflectionFunction: {
  39609. name: string;
  39610. shader: string;
  39611. };
  39612. }
  39613. declare module BABYLON {
  39614. /** @hidden */
  39615. export var bumpFragmentFunctions: {
  39616. name: string;
  39617. shader: string;
  39618. };
  39619. }
  39620. declare module BABYLON {
  39621. /** @hidden */
  39622. export var logDepthDeclaration: {
  39623. name: string;
  39624. shader: string;
  39625. };
  39626. }
  39627. declare module BABYLON {
  39628. /** @hidden */
  39629. export var bumpFragment: {
  39630. name: string;
  39631. shader: string;
  39632. };
  39633. }
  39634. declare module BABYLON {
  39635. /** @hidden */
  39636. export var depthPrePass: {
  39637. name: string;
  39638. shader: string;
  39639. };
  39640. }
  39641. declare module BABYLON {
  39642. /** @hidden */
  39643. export var lightFragment: {
  39644. name: string;
  39645. shader: string;
  39646. };
  39647. }
  39648. declare module BABYLON {
  39649. /** @hidden */
  39650. export var logDepthFragment: {
  39651. name: string;
  39652. shader: string;
  39653. };
  39654. }
  39655. declare module BABYLON {
  39656. /** @hidden */
  39657. export var defaultPixelShader: {
  39658. name: string;
  39659. shader: string;
  39660. };
  39661. }
  39662. declare module BABYLON {
  39663. /** @hidden */
  39664. export var defaultVertexDeclaration: {
  39665. name: string;
  39666. shader: string;
  39667. };
  39668. }
  39669. declare module BABYLON {
  39670. /** @hidden */
  39671. export var bumpVertexDeclaration: {
  39672. name: string;
  39673. shader: string;
  39674. };
  39675. }
  39676. declare module BABYLON {
  39677. /** @hidden */
  39678. export var bumpVertex: {
  39679. name: string;
  39680. shader: string;
  39681. };
  39682. }
  39683. declare module BABYLON {
  39684. /** @hidden */
  39685. export var fogVertex: {
  39686. name: string;
  39687. shader: string;
  39688. };
  39689. }
  39690. declare module BABYLON {
  39691. /** @hidden */
  39692. export var shadowsVertex: {
  39693. name: string;
  39694. shader: string;
  39695. };
  39696. }
  39697. declare module BABYLON {
  39698. /** @hidden */
  39699. export var pointCloudVertex: {
  39700. name: string;
  39701. shader: string;
  39702. };
  39703. }
  39704. declare module BABYLON {
  39705. /** @hidden */
  39706. export var logDepthVertex: {
  39707. name: string;
  39708. shader: string;
  39709. };
  39710. }
  39711. declare module BABYLON {
  39712. /** @hidden */
  39713. export var defaultVertexShader: {
  39714. name: string;
  39715. shader: string;
  39716. };
  39717. }
  39718. declare module BABYLON {
  39719. /** @hidden */
  39720. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39721. MAINUV1: boolean;
  39722. MAINUV2: boolean;
  39723. DIFFUSE: boolean;
  39724. DIFFUSEDIRECTUV: number;
  39725. AMBIENT: boolean;
  39726. AMBIENTDIRECTUV: number;
  39727. OPACITY: boolean;
  39728. OPACITYDIRECTUV: number;
  39729. OPACITYRGB: boolean;
  39730. REFLECTION: boolean;
  39731. EMISSIVE: boolean;
  39732. EMISSIVEDIRECTUV: number;
  39733. SPECULAR: boolean;
  39734. SPECULARDIRECTUV: number;
  39735. BUMP: boolean;
  39736. BUMPDIRECTUV: number;
  39737. PARALLAX: boolean;
  39738. PARALLAXOCCLUSION: boolean;
  39739. SPECULAROVERALPHA: boolean;
  39740. CLIPPLANE: boolean;
  39741. CLIPPLANE2: boolean;
  39742. CLIPPLANE3: boolean;
  39743. CLIPPLANE4: boolean;
  39744. ALPHATEST: boolean;
  39745. DEPTHPREPASS: boolean;
  39746. ALPHAFROMDIFFUSE: boolean;
  39747. POINTSIZE: boolean;
  39748. FOG: boolean;
  39749. SPECULARTERM: boolean;
  39750. DIFFUSEFRESNEL: boolean;
  39751. OPACITYFRESNEL: boolean;
  39752. REFLECTIONFRESNEL: boolean;
  39753. REFRACTIONFRESNEL: boolean;
  39754. EMISSIVEFRESNEL: boolean;
  39755. FRESNEL: boolean;
  39756. NORMAL: boolean;
  39757. UV1: boolean;
  39758. UV2: boolean;
  39759. VERTEXCOLOR: boolean;
  39760. VERTEXALPHA: boolean;
  39761. NUM_BONE_INFLUENCERS: number;
  39762. BonesPerMesh: number;
  39763. BONETEXTURE: boolean;
  39764. INSTANCES: boolean;
  39765. GLOSSINESS: boolean;
  39766. ROUGHNESS: boolean;
  39767. EMISSIVEASILLUMINATION: boolean;
  39768. LINKEMISSIVEWITHDIFFUSE: boolean;
  39769. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39770. LIGHTMAP: boolean;
  39771. LIGHTMAPDIRECTUV: number;
  39772. OBJECTSPACE_NORMALMAP: boolean;
  39773. USELIGHTMAPASSHADOWMAP: boolean;
  39774. REFLECTIONMAP_3D: boolean;
  39775. REFLECTIONMAP_SPHERICAL: boolean;
  39776. REFLECTIONMAP_PLANAR: boolean;
  39777. REFLECTIONMAP_CUBIC: boolean;
  39778. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39779. REFLECTIONMAP_PROJECTION: boolean;
  39780. REFLECTIONMAP_SKYBOX: boolean;
  39781. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39782. REFLECTIONMAP_EXPLICIT: boolean;
  39783. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39784. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39785. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39786. INVERTCUBICMAP: boolean;
  39787. LOGARITHMICDEPTH: boolean;
  39788. REFRACTION: boolean;
  39789. REFRACTIONMAP_3D: boolean;
  39790. REFLECTIONOVERALPHA: boolean;
  39791. TWOSIDEDLIGHTING: boolean;
  39792. SHADOWFLOAT: boolean;
  39793. MORPHTARGETS: boolean;
  39794. MORPHTARGETS_NORMAL: boolean;
  39795. MORPHTARGETS_TANGENT: boolean;
  39796. MORPHTARGETS_UV: boolean;
  39797. NUM_MORPH_INFLUENCERS: number;
  39798. NONUNIFORMSCALING: boolean;
  39799. PREMULTIPLYALPHA: boolean;
  39800. IMAGEPROCESSING: boolean;
  39801. VIGNETTE: boolean;
  39802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39803. VIGNETTEBLENDMODEOPAQUE: boolean;
  39804. TONEMAPPING: boolean;
  39805. TONEMAPPING_ACES: boolean;
  39806. CONTRAST: boolean;
  39807. COLORCURVES: boolean;
  39808. COLORGRADING: boolean;
  39809. COLORGRADING3D: boolean;
  39810. SAMPLER3DGREENDEPTH: boolean;
  39811. SAMPLER3DBGRMAP: boolean;
  39812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39813. MULTIVIEW: boolean;
  39814. /**
  39815. * If the reflection texture on this material is in linear color space
  39816. * @hidden
  39817. */
  39818. IS_REFLECTION_LINEAR: boolean;
  39819. /**
  39820. * If the refraction texture on this material is in linear color space
  39821. * @hidden
  39822. */
  39823. IS_REFRACTION_LINEAR: boolean;
  39824. EXPOSURE: boolean;
  39825. constructor();
  39826. setReflectionMode(modeToEnable: string): void;
  39827. }
  39828. /**
  39829. * This is the default material used in Babylon. It is the best trade off between quality
  39830. * and performances.
  39831. * @see http://doc.babylonjs.com/babylon101/materials
  39832. */
  39833. export class StandardMaterial extends PushMaterial {
  39834. private _diffuseTexture;
  39835. /**
  39836. * The basic texture of the material as viewed under a light.
  39837. */
  39838. diffuseTexture: Nullable<BaseTexture>;
  39839. private _ambientTexture;
  39840. /**
  39841. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39842. */
  39843. ambientTexture: Nullable<BaseTexture>;
  39844. private _opacityTexture;
  39845. /**
  39846. * Define the transparency of the material from a texture.
  39847. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39848. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39849. */
  39850. opacityTexture: Nullable<BaseTexture>;
  39851. private _reflectionTexture;
  39852. /**
  39853. * Define the texture used to display the reflection.
  39854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39855. */
  39856. reflectionTexture: Nullable<BaseTexture>;
  39857. private _emissiveTexture;
  39858. /**
  39859. * Define texture of the material as if self lit.
  39860. * This will be mixed in the final result even in the absence of light.
  39861. */
  39862. emissiveTexture: Nullable<BaseTexture>;
  39863. private _specularTexture;
  39864. /**
  39865. * Define how the color and intensity of the highlight given by the light in the material.
  39866. */
  39867. specularTexture: Nullable<BaseTexture>;
  39868. private _bumpTexture;
  39869. /**
  39870. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39871. * 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.
  39872. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39873. */
  39874. bumpTexture: Nullable<BaseTexture>;
  39875. private _lightmapTexture;
  39876. /**
  39877. * Complex lighting can be computationally expensive to compute at runtime.
  39878. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39879. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39880. */
  39881. lightmapTexture: Nullable<BaseTexture>;
  39882. private _refractionTexture;
  39883. /**
  39884. * Define the texture used to display the refraction.
  39885. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39886. */
  39887. refractionTexture: Nullable<BaseTexture>;
  39888. /**
  39889. * The color of the material lit by the environmental background lighting.
  39890. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39891. */
  39892. ambientColor: Color3;
  39893. /**
  39894. * The basic color of the material as viewed under a light.
  39895. */
  39896. diffuseColor: Color3;
  39897. /**
  39898. * Define how the color and intensity of the highlight given by the light in the material.
  39899. */
  39900. specularColor: Color3;
  39901. /**
  39902. * Define the color of the material as if self lit.
  39903. * This will be mixed in the final result even in the absence of light.
  39904. */
  39905. emissiveColor: Color3;
  39906. /**
  39907. * Defines how sharp are the highlights in the material.
  39908. * The bigger the value the sharper giving a more glossy feeling to the result.
  39909. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39910. */
  39911. specularPower: number;
  39912. private _useAlphaFromDiffuseTexture;
  39913. /**
  39914. * Does the transparency come from the diffuse texture alpha channel.
  39915. */
  39916. useAlphaFromDiffuseTexture: boolean;
  39917. private _useEmissiveAsIllumination;
  39918. /**
  39919. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39920. */
  39921. useEmissiveAsIllumination: boolean;
  39922. private _linkEmissiveWithDiffuse;
  39923. /**
  39924. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39925. * the emissive level when the final color is close to one.
  39926. */
  39927. linkEmissiveWithDiffuse: boolean;
  39928. private _useSpecularOverAlpha;
  39929. /**
  39930. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39931. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39932. */
  39933. useSpecularOverAlpha: boolean;
  39934. private _useReflectionOverAlpha;
  39935. /**
  39936. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39937. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39938. */
  39939. useReflectionOverAlpha: boolean;
  39940. private _disableLighting;
  39941. /**
  39942. * Does lights from the scene impacts this material.
  39943. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39944. */
  39945. disableLighting: boolean;
  39946. private _useObjectSpaceNormalMap;
  39947. /**
  39948. * Allows using an object space normal map (instead of tangent space).
  39949. */
  39950. useObjectSpaceNormalMap: boolean;
  39951. private _useParallax;
  39952. /**
  39953. * Is parallax enabled or not.
  39954. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39955. */
  39956. useParallax: boolean;
  39957. private _useParallaxOcclusion;
  39958. /**
  39959. * Is parallax occlusion enabled or not.
  39960. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39961. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39962. */
  39963. useParallaxOcclusion: boolean;
  39964. /**
  39965. * 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.
  39966. */
  39967. parallaxScaleBias: number;
  39968. private _roughness;
  39969. /**
  39970. * Helps to define how blurry the reflections should appears in the material.
  39971. */
  39972. roughness: number;
  39973. /**
  39974. * In case of refraction, define the value of the index of refraction.
  39975. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39976. */
  39977. indexOfRefraction: number;
  39978. /**
  39979. * Invert the refraction texture alongside the y axis.
  39980. * It can be useful with procedural textures or probe for instance.
  39981. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39982. */
  39983. invertRefractionY: boolean;
  39984. /**
  39985. * Defines the alpha limits in alpha test mode.
  39986. */
  39987. alphaCutOff: number;
  39988. private _useLightmapAsShadowmap;
  39989. /**
  39990. * In case of light mapping, define whether the map contains light or shadow informations.
  39991. */
  39992. useLightmapAsShadowmap: boolean;
  39993. private _diffuseFresnelParameters;
  39994. /**
  39995. * Define the diffuse fresnel parameters of the material.
  39996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39997. */
  39998. diffuseFresnelParameters: FresnelParameters;
  39999. private _opacityFresnelParameters;
  40000. /**
  40001. * Define the opacity fresnel parameters of the material.
  40002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40003. */
  40004. opacityFresnelParameters: FresnelParameters;
  40005. private _reflectionFresnelParameters;
  40006. /**
  40007. * Define the reflection fresnel parameters of the material.
  40008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40009. */
  40010. reflectionFresnelParameters: FresnelParameters;
  40011. private _refractionFresnelParameters;
  40012. /**
  40013. * Define the refraction fresnel parameters of the material.
  40014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40015. */
  40016. refractionFresnelParameters: FresnelParameters;
  40017. private _emissiveFresnelParameters;
  40018. /**
  40019. * Define the emissive fresnel parameters of the material.
  40020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40021. */
  40022. emissiveFresnelParameters: FresnelParameters;
  40023. private _useReflectionFresnelFromSpecular;
  40024. /**
  40025. * If true automatically deducts the fresnels values from the material specularity.
  40026. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40027. */
  40028. useReflectionFresnelFromSpecular: boolean;
  40029. private _useGlossinessFromSpecularMapAlpha;
  40030. /**
  40031. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40032. */
  40033. useGlossinessFromSpecularMapAlpha: boolean;
  40034. private _maxSimultaneousLights;
  40035. /**
  40036. * Defines the maximum number of lights that can be used in the material
  40037. */
  40038. maxSimultaneousLights: number;
  40039. private _invertNormalMapX;
  40040. /**
  40041. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40042. */
  40043. invertNormalMapX: boolean;
  40044. private _invertNormalMapY;
  40045. /**
  40046. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40047. */
  40048. invertNormalMapY: boolean;
  40049. private _twoSidedLighting;
  40050. /**
  40051. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40052. */
  40053. twoSidedLighting: boolean;
  40054. /**
  40055. * Default configuration related to image processing available in the standard Material.
  40056. */
  40057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40058. /**
  40059. * Gets the image processing configuration used either in this material.
  40060. */
  40061. /**
  40062. * Sets the Default image processing configuration used either in the this material.
  40063. *
  40064. * If sets to null, the scene one is in use.
  40065. */
  40066. imageProcessingConfiguration: ImageProcessingConfiguration;
  40067. /**
  40068. * Keep track of the image processing observer to allow dispose and replace.
  40069. */
  40070. private _imageProcessingObserver;
  40071. /**
  40072. * Attaches a new image processing configuration to the Standard Material.
  40073. * @param configuration
  40074. */
  40075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40076. /**
  40077. * Gets wether the color curves effect is enabled.
  40078. */
  40079. /**
  40080. * Sets wether the color curves effect is enabled.
  40081. */
  40082. cameraColorCurvesEnabled: boolean;
  40083. /**
  40084. * Gets wether the color grading effect is enabled.
  40085. */
  40086. /**
  40087. * Gets wether the color grading effect is enabled.
  40088. */
  40089. cameraColorGradingEnabled: boolean;
  40090. /**
  40091. * Gets wether tonemapping is enabled or not.
  40092. */
  40093. /**
  40094. * Sets wether tonemapping is enabled or not
  40095. */
  40096. cameraToneMappingEnabled: boolean;
  40097. /**
  40098. * The camera exposure used on this material.
  40099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40100. * This corresponds to a photographic exposure.
  40101. */
  40102. /**
  40103. * The camera exposure used on this material.
  40104. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40105. * This corresponds to a photographic exposure.
  40106. */
  40107. cameraExposure: number;
  40108. /**
  40109. * Gets The camera contrast used on this material.
  40110. */
  40111. /**
  40112. * Sets The camera contrast used on this material.
  40113. */
  40114. cameraContrast: number;
  40115. /**
  40116. * Gets the Color Grading 2D Lookup Texture.
  40117. */
  40118. /**
  40119. * Sets the Color Grading 2D Lookup Texture.
  40120. */
  40121. cameraColorGradingTexture: Nullable<BaseTexture>;
  40122. /**
  40123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40125. * 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;
  40126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40127. */
  40128. /**
  40129. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40131. * 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;
  40132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40133. */
  40134. cameraColorCurves: Nullable<ColorCurves>;
  40135. /**
  40136. * Custom callback helping to override the default shader used in the material.
  40137. */
  40138. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40139. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40140. protected _worldViewProjectionMatrix: Matrix;
  40141. protected _globalAmbientColor: Color3;
  40142. protected _useLogarithmicDepth: boolean;
  40143. /**
  40144. * Instantiates a new standard material.
  40145. * This is the default material used in Babylon. It is the best trade off between quality
  40146. * and performances.
  40147. * @see http://doc.babylonjs.com/babylon101/materials
  40148. * @param name Define the name of the material in the scene
  40149. * @param scene Define the scene the material belong to
  40150. */
  40151. constructor(name: string, scene: Scene);
  40152. /**
  40153. * Gets a boolean indicating that current material needs to register RTT
  40154. */
  40155. readonly hasRenderTargetTextures: boolean;
  40156. /**
  40157. * Gets the current class name of the material e.g. "StandardMaterial"
  40158. * Mainly use in serialization.
  40159. * @returns the class name
  40160. */
  40161. getClassName(): string;
  40162. /**
  40163. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40164. * You can try switching to logarithmic depth.
  40165. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40166. */
  40167. useLogarithmicDepth: boolean;
  40168. /**
  40169. * Specifies if the material will require alpha blending
  40170. * @returns a boolean specifying if alpha blending is needed
  40171. */
  40172. needAlphaBlending(): boolean;
  40173. /**
  40174. * Specifies if this material should be rendered in alpha test mode
  40175. * @returns a boolean specifying if an alpha test is needed.
  40176. */
  40177. needAlphaTesting(): boolean;
  40178. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40179. /**
  40180. * Get the texture used for alpha test purpose.
  40181. * @returns the diffuse texture in case of the standard material.
  40182. */
  40183. getAlphaTestTexture(): Nullable<BaseTexture>;
  40184. /**
  40185. * Get if the submesh is ready to be used and all its information available.
  40186. * Child classes can use it to update shaders
  40187. * @param mesh defines the mesh to check
  40188. * @param subMesh defines which submesh to check
  40189. * @param useInstances specifies that instances should be used
  40190. * @returns a boolean indicating that the submesh is ready or not
  40191. */
  40192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40193. /**
  40194. * Builds the material UBO layouts.
  40195. * Used internally during the effect preparation.
  40196. */
  40197. buildUniformLayout(): void;
  40198. /**
  40199. * Unbinds the material from the mesh
  40200. */
  40201. unbind(): void;
  40202. /**
  40203. * Binds the submesh to this material by preparing the effect and shader to draw
  40204. * @param world defines the world transformation matrix
  40205. * @param mesh defines the mesh containing the submesh
  40206. * @param subMesh defines the submesh to bind the material to
  40207. */
  40208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40209. /**
  40210. * Get the list of animatables in the material.
  40211. * @returns the list of animatables object used in the material
  40212. */
  40213. getAnimatables(): IAnimatable[];
  40214. /**
  40215. * Gets the active textures from the material
  40216. * @returns an array of textures
  40217. */
  40218. getActiveTextures(): BaseTexture[];
  40219. /**
  40220. * Specifies if the material uses a texture
  40221. * @param texture defines the texture to check against the material
  40222. * @returns a boolean specifying if the material uses the texture
  40223. */
  40224. hasTexture(texture: BaseTexture): boolean;
  40225. /**
  40226. * Disposes the material
  40227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40229. */
  40230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40231. /**
  40232. * Makes a duplicate of the material, and gives it a new name
  40233. * @param name defines the new name for the duplicated material
  40234. * @returns the cloned material
  40235. */
  40236. clone(name: string): StandardMaterial;
  40237. /**
  40238. * Serializes this material in a JSON representation
  40239. * @returns the serialized material object
  40240. */
  40241. serialize(): any;
  40242. /**
  40243. * Creates a standard material from parsed material data
  40244. * @param source defines the JSON representation of the material
  40245. * @param scene defines the hosting scene
  40246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40247. * @returns a new standard material
  40248. */
  40249. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40250. /**
  40251. * Are diffuse textures enabled in the application.
  40252. */
  40253. static DiffuseTextureEnabled: boolean;
  40254. /**
  40255. * Are ambient textures enabled in the application.
  40256. */
  40257. static AmbientTextureEnabled: boolean;
  40258. /**
  40259. * Are opacity textures enabled in the application.
  40260. */
  40261. static OpacityTextureEnabled: boolean;
  40262. /**
  40263. * Are reflection textures enabled in the application.
  40264. */
  40265. static ReflectionTextureEnabled: boolean;
  40266. /**
  40267. * Are emissive textures enabled in the application.
  40268. */
  40269. static EmissiveTextureEnabled: boolean;
  40270. /**
  40271. * Are specular textures enabled in the application.
  40272. */
  40273. static SpecularTextureEnabled: boolean;
  40274. /**
  40275. * Are bump textures enabled in the application.
  40276. */
  40277. static BumpTextureEnabled: boolean;
  40278. /**
  40279. * Are lightmap textures enabled in the application.
  40280. */
  40281. static LightmapTextureEnabled: boolean;
  40282. /**
  40283. * Are refraction textures enabled in the application.
  40284. */
  40285. static RefractionTextureEnabled: boolean;
  40286. /**
  40287. * Are color grading textures enabled in the application.
  40288. */
  40289. static ColorGradingTextureEnabled: boolean;
  40290. /**
  40291. * Are fresnels enabled in the application.
  40292. */
  40293. static FresnelEnabled: boolean;
  40294. }
  40295. }
  40296. declare module BABYLON {
  40297. /**
  40298. * A class extending Texture allowing drawing on a texture
  40299. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40300. */
  40301. export class DynamicTexture extends Texture {
  40302. private _generateMipMaps;
  40303. private _canvas;
  40304. private _context;
  40305. private _engine;
  40306. /**
  40307. * Creates a DynamicTexture
  40308. * @param name defines the name of the texture
  40309. * @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
  40310. * @param scene defines the scene where you want the texture
  40311. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40312. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40313. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40314. */
  40315. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40316. /**
  40317. * Get the current class name of the texture useful for serialization or dynamic coding.
  40318. * @returns "DynamicTexture"
  40319. */
  40320. getClassName(): string;
  40321. /**
  40322. * Gets the current state of canRescale
  40323. */
  40324. readonly canRescale: boolean;
  40325. private _recreate;
  40326. /**
  40327. * Scales the texture
  40328. * @param ratio the scale factor to apply to both width and height
  40329. */
  40330. scale(ratio: number): void;
  40331. /**
  40332. * Resizes the texture
  40333. * @param width the new width
  40334. * @param height the new height
  40335. */
  40336. scaleTo(width: number, height: number): void;
  40337. /**
  40338. * Gets the context of the canvas used by the texture
  40339. * @returns the canvas context of the dynamic texture
  40340. */
  40341. getContext(): CanvasRenderingContext2D;
  40342. /**
  40343. * Clears the texture
  40344. */
  40345. clear(): void;
  40346. /**
  40347. * Updates the texture
  40348. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40349. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40350. */
  40351. update(invertY?: boolean, premulAlpha?: boolean): void;
  40352. /**
  40353. * Draws text onto the texture
  40354. * @param text defines the text to be drawn
  40355. * @param x defines the placement of the text from the left
  40356. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40357. * @param font defines the font to be used with font-style, font-size, font-name
  40358. * @param color defines the color used for the text
  40359. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40360. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40361. * @param update defines whether texture is immediately update (default is true)
  40362. */
  40363. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40364. /**
  40365. * Clones the texture
  40366. * @returns the clone of the texture.
  40367. */
  40368. clone(): DynamicTexture;
  40369. /**
  40370. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40371. * @returns a serialized dynamic texture object
  40372. */
  40373. serialize(): any;
  40374. /** @hidden */
  40375. _rebuild(): void;
  40376. }
  40377. }
  40378. declare module BABYLON {
  40379. /** @hidden */
  40380. export var imageProcessingPixelShader: {
  40381. name: string;
  40382. shader: string;
  40383. };
  40384. }
  40385. declare module BABYLON {
  40386. /**
  40387. * ImageProcessingPostProcess
  40388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40389. */
  40390. export class ImageProcessingPostProcess extends PostProcess {
  40391. /**
  40392. * Default configuration related to image processing available in the PBR Material.
  40393. */
  40394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40395. /**
  40396. * Gets the image processing configuration used either in this material.
  40397. */
  40398. /**
  40399. * Sets the Default image processing configuration used either in the this material.
  40400. *
  40401. * If sets to null, the scene one is in use.
  40402. */
  40403. imageProcessingConfiguration: ImageProcessingConfiguration;
  40404. /**
  40405. * Keep track of the image processing observer to allow dispose and replace.
  40406. */
  40407. private _imageProcessingObserver;
  40408. /**
  40409. * Attaches a new image processing configuration to the PBR Material.
  40410. * @param configuration
  40411. */
  40412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40413. /**
  40414. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40415. */
  40416. /**
  40417. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40418. */
  40419. colorCurves: Nullable<ColorCurves>;
  40420. /**
  40421. * Gets wether the color curves effect is enabled.
  40422. */
  40423. /**
  40424. * Sets wether the color curves effect is enabled.
  40425. */
  40426. colorCurvesEnabled: boolean;
  40427. /**
  40428. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40429. */
  40430. /**
  40431. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40432. */
  40433. colorGradingTexture: Nullable<BaseTexture>;
  40434. /**
  40435. * Gets wether the color grading effect is enabled.
  40436. */
  40437. /**
  40438. * Gets wether the color grading effect is enabled.
  40439. */
  40440. colorGradingEnabled: boolean;
  40441. /**
  40442. * Gets exposure used in the effect.
  40443. */
  40444. /**
  40445. * Sets exposure used in the effect.
  40446. */
  40447. exposure: number;
  40448. /**
  40449. * Gets wether tonemapping is enabled or not.
  40450. */
  40451. /**
  40452. * Sets wether tonemapping is enabled or not
  40453. */
  40454. toneMappingEnabled: boolean;
  40455. /**
  40456. * Gets the type of tone mapping effect.
  40457. */
  40458. /**
  40459. * Sets the type of tone mapping effect.
  40460. */
  40461. toneMappingType: number;
  40462. /**
  40463. * Gets contrast used in the effect.
  40464. */
  40465. /**
  40466. * Sets contrast used in the effect.
  40467. */
  40468. contrast: number;
  40469. /**
  40470. * Gets Vignette stretch size.
  40471. */
  40472. /**
  40473. * Sets Vignette stretch size.
  40474. */
  40475. vignetteStretch: number;
  40476. /**
  40477. * Gets Vignette centre X Offset.
  40478. */
  40479. /**
  40480. * Sets Vignette centre X Offset.
  40481. */
  40482. vignetteCentreX: number;
  40483. /**
  40484. * Gets Vignette centre Y Offset.
  40485. */
  40486. /**
  40487. * Sets Vignette centre Y Offset.
  40488. */
  40489. vignetteCentreY: number;
  40490. /**
  40491. * Gets Vignette weight or intensity of the vignette effect.
  40492. */
  40493. /**
  40494. * Sets Vignette weight or intensity of the vignette effect.
  40495. */
  40496. vignetteWeight: number;
  40497. /**
  40498. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40499. * if vignetteEnabled is set to true.
  40500. */
  40501. /**
  40502. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40503. * if vignetteEnabled is set to true.
  40504. */
  40505. vignetteColor: Color4;
  40506. /**
  40507. * Gets Camera field of view used by the Vignette effect.
  40508. */
  40509. /**
  40510. * Sets Camera field of view used by the Vignette effect.
  40511. */
  40512. vignetteCameraFov: number;
  40513. /**
  40514. * Gets the vignette blend mode allowing different kind of effect.
  40515. */
  40516. /**
  40517. * Sets the vignette blend mode allowing different kind of effect.
  40518. */
  40519. vignetteBlendMode: number;
  40520. /**
  40521. * Gets wether the vignette effect is enabled.
  40522. */
  40523. /**
  40524. * Sets wether the vignette effect is enabled.
  40525. */
  40526. vignetteEnabled: boolean;
  40527. private _fromLinearSpace;
  40528. /**
  40529. * Gets wether the input of the processing is in Gamma or Linear Space.
  40530. */
  40531. /**
  40532. * Sets wether the input of the processing is in Gamma or Linear Space.
  40533. */
  40534. fromLinearSpace: boolean;
  40535. /**
  40536. * Defines cache preventing GC.
  40537. */
  40538. private _defines;
  40539. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40540. /**
  40541. * "ImageProcessingPostProcess"
  40542. * @returns "ImageProcessingPostProcess"
  40543. */
  40544. getClassName(): string;
  40545. protected _updateParameters(): void;
  40546. dispose(camera?: Camera): void;
  40547. }
  40548. }
  40549. declare module BABYLON {
  40550. /**
  40551. * Class containing static functions to help procedurally build meshes
  40552. */
  40553. export class GroundBuilder {
  40554. /**
  40555. * Creates a ground mesh
  40556. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40557. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40559. * @param name defines the name of the mesh
  40560. * @param options defines the options used to create the mesh
  40561. * @param scene defines the hosting scene
  40562. * @returns the ground mesh
  40563. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40564. */
  40565. static CreateGround(name: string, options: {
  40566. width?: number;
  40567. height?: number;
  40568. subdivisions?: number;
  40569. subdivisionsX?: number;
  40570. subdivisionsY?: number;
  40571. updatable?: boolean;
  40572. }, scene: any): Mesh;
  40573. /**
  40574. * Creates a tiled ground mesh
  40575. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40576. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40577. * * 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
  40578. * * 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
  40579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40580. * @param name defines the name of the mesh
  40581. * @param options defines the options used to create the mesh
  40582. * @param scene defines the hosting scene
  40583. * @returns the tiled ground mesh
  40584. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40585. */
  40586. static CreateTiledGround(name: string, options: {
  40587. xmin: number;
  40588. zmin: number;
  40589. xmax: number;
  40590. zmax: number;
  40591. subdivisions?: {
  40592. w: number;
  40593. h: number;
  40594. };
  40595. precision?: {
  40596. w: number;
  40597. h: number;
  40598. };
  40599. updatable?: boolean;
  40600. }, scene?: Nullable<Scene>): Mesh;
  40601. /**
  40602. * Creates a ground mesh from a height map
  40603. * * The parameter `url` sets the URL of the height map image resource.
  40604. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40605. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40606. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40607. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40608. * * 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.
  40609. * * 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).
  40610. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40612. * @param name defines the name of the mesh
  40613. * @param url defines the url to the height map
  40614. * @param options defines the options used to create the mesh
  40615. * @param scene defines the hosting scene
  40616. * @returns the ground mesh
  40617. * @see https://doc.babylonjs.com/babylon101/height_map
  40618. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40619. */
  40620. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40621. width?: number;
  40622. height?: number;
  40623. subdivisions?: number;
  40624. minHeight?: number;
  40625. maxHeight?: number;
  40626. colorFilter?: Color3;
  40627. alphaFilter?: number;
  40628. updatable?: boolean;
  40629. onReady?: (mesh: GroundMesh) => void;
  40630. }, scene?: Nullable<Scene>): GroundMesh;
  40631. }
  40632. }
  40633. declare module BABYLON {
  40634. /**
  40635. * Class containing static functions to help procedurally build meshes
  40636. */
  40637. export class TorusBuilder {
  40638. /**
  40639. * Creates a torus mesh
  40640. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40641. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40642. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40644. * * 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
  40645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40646. * @param name defines the name of the mesh
  40647. * @param options defines the options used to create the mesh
  40648. * @param scene defines the hosting scene
  40649. * @returns the torus mesh
  40650. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40651. */
  40652. static CreateTorus(name: string, options: {
  40653. diameter?: number;
  40654. thickness?: number;
  40655. tessellation?: number;
  40656. updatable?: boolean;
  40657. sideOrientation?: number;
  40658. frontUVs?: Vector4;
  40659. backUVs?: Vector4;
  40660. }, scene: any): Mesh;
  40661. }
  40662. }
  40663. declare module BABYLON {
  40664. /**
  40665. * Class containing static functions to help procedurally build meshes
  40666. */
  40667. export class CylinderBuilder {
  40668. /**
  40669. * Creates a cylinder or a cone mesh
  40670. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40671. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40672. * * 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.
  40673. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40674. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40675. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40676. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40677. * * 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).
  40678. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40679. * * 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).
  40680. * * 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
  40681. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40682. * * 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
  40683. * * 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.
  40684. * * If `enclose` is false, a ring surface is one element.
  40685. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40686. * * 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
  40687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40688. * * 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
  40689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40690. * @param name defines the name of the mesh
  40691. * @param options defines the options used to create the mesh
  40692. * @param scene defines the hosting scene
  40693. * @returns the cylinder mesh
  40694. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40695. */
  40696. static CreateCylinder(name: string, options: {
  40697. height?: number;
  40698. diameterTop?: number;
  40699. diameterBottom?: number;
  40700. diameter?: number;
  40701. tessellation?: number;
  40702. subdivisions?: number;
  40703. arc?: number;
  40704. faceColors?: Color4[];
  40705. faceUV?: Vector4[];
  40706. updatable?: boolean;
  40707. hasRings?: boolean;
  40708. enclose?: boolean;
  40709. cap?: number;
  40710. sideOrientation?: number;
  40711. frontUVs?: Vector4;
  40712. backUVs?: Vector4;
  40713. }, scene: any): Mesh;
  40714. }
  40715. }
  40716. declare module BABYLON {
  40717. /**
  40718. * Options to modify the vr teleportation behavior.
  40719. */
  40720. export interface VRTeleportationOptions {
  40721. /**
  40722. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40723. */
  40724. floorMeshName?: string;
  40725. /**
  40726. * A list of meshes to be used as the teleportation floor. (default: empty)
  40727. */
  40728. floorMeshes?: Mesh[];
  40729. }
  40730. /**
  40731. * Options to modify the vr experience helper's behavior.
  40732. */
  40733. export interface VRExperienceHelperOptions extends WebVROptions {
  40734. /**
  40735. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40736. */
  40737. createDeviceOrientationCamera?: boolean;
  40738. /**
  40739. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40740. */
  40741. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40742. /**
  40743. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40744. */
  40745. laserToggle?: boolean;
  40746. /**
  40747. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40748. */
  40749. floorMeshes?: Mesh[];
  40750. /**
  40751. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40752. */
  40753. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40754. }
  40755. /**
  40756. * Event containing information after VR has been entered
  40757. */
  40758. export class OnAfterEnteringVRObservableEvent {
  40759. /**
  40760. * If entering vr was successful
  40761. */
  40762. success: boolean;
  40763. }
  40764. /**
  40765. * Helps to quickly add VR support to an existing scene.
  40766. * See http://doc.babylonjs.com/how_to/webvr_helper
  40767. */
  40768. export class VRExperienceHelper {
  40769. /** Options to modify the vr experience helper's behavior. */
  40770. webVROptions: VRExperienceHelperOptions;
  40771. private _scene;
  40772. private _position;
  40773. private _btnVR;
  40774. private _btnVRDisplayed;
  40775. private _webVRsupported;
  40776. private _webVRready;
  40777. private _webVRrequesting;
  40778. private _webVRpresenting;
  40779. private _hasEnteredVR;
  40780. private _fullscreenVRpresenting;
  40781. private _canvas;
  40782. private _webVRCamera;
  40783. private _vrDeviceOrientationCamera;
  40784. private _deviceOrientationCamera;
  40785. private _existingCamera;
  40786. private _onKeyDown;
  40787. private _onVrDisplayPresentChange;
  40788. private _onVRDisplayChanged;
  40789. private _onVRRequestPresentStart;
  40790. private _onVRRequestPresentComplete;
  40791. /**
  40792. * 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)
  40793. */
  40794. enableGazeEvenWhenNoPointerLock: boolean;
  40795. /**
  40796. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40797. */
  40798. exitVROnDoubleTap: boolean;
  40799. /**
  40800. * Observable raised right before entering VR.
  40801. */
  40802. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40803. /**
  40804. * Observable raised when entering VR has completed.
  40805. */
  40806. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40807. /**
  40808. * Observable raised when exiting VR.
  40809. */
  40810. onExitingVRObservable: Observable<VRExperienceHelper>;
  40811. /**
  40812. * Observable raised when controller mesh is loaded.
  40813. */
  40814. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40815. /** Return this.onEnteringVRObservable
  40816. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40817. */
  40818. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40819. /** Return this.onExitingVRObservable
  40820. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40821. */
  40822. readonly onExitingVR: Observable<VRExperienceHelper>;
  40823. /** Return this.onControllerMeshLoadedObservable
  40824. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40825. */
  40826. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40827. private _rayLength;
  40828. private _useCustomVRButton;
  40829. private _teleportationRequested;
  40830. private _teleportActive;
  40831. private _floorMeshName;
  40832. private _floorMeshesCollection;
  40833. private _rotationAllowed;
  40834. private _teleportBackwardsVector;
  40835. private _teleportationTarget;
  40836. private _isDefaultTeleportationTarget;
  40837. private _postProcessMove;
  40838. private _teleportationFillColor;
  40839. private _teleportationBorderColor;
  40840. private _rotationAngle;
  40841. private _haloCenter;
  40842. private _cameraGazer;
  40843. private _padSensibilityUp;
  40844. private _padSensibilityDown;
  40845. private _leftController;
  40846. private _rightController;
  40847. /**
  40848. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40849. */
  40850. onNewMeshSelected: Observable<AbstractMesh>;
  40851. /**
  40852. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40853. */
  40854. onNewMeshPicked: Observable<PickingInfo>;
  40855. private _circleEase;
  40856. /**
  40857. * Observable raised before camera teleportation
  40858. */
  40859. onBeforeCameraTeleport: Observable<Vector3>;
  40860. /**
  40861. * Observable raised after camera teleportation
  40862. */
  40863. onAfterCameraTeleport: Observable<Vector3>;
  40864. /**
  40865. * Observable raised when current selected mesh gets unselected
  40866. */
  40867. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40868. private _raySelectionPredicate;
  40869. /**
  40870. * To be optionaly changed by user to define custom ray selection
  40871. */
  40872. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40873. /**
  40874. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40875. */
  40876. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40877. /**
  40878. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40879. */
  40880. teleportationEnabled: boolean;
  40881. private _defaultHeight;
  40882. private _teleportationInitialized;
  40883. private _interactionsEnabled;
  40884. private _interactionsRequested;
  40885. private _displayGaze;
  40886. private _displayLaserPointer;
  40887. /**
  40888. * The mesh used to display where the user is going to teleport.
  40889. */
  40890. /**
  40891. * Sets the mesh to be used to display where the user is going to teleport.
  40892. */
  40893. teleportationTarget: Mesh;
  40894. /**
  40895. * 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
  40896. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40897. * See http://doc.babylonjs.com/resources/baking_transformations
  40898. */
  40899. gazeTrackerMesh: Mesh;
  40900. /**
  40901. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40902. */
  40903. updateGazeTrackerScale: boolean;
  40904. /**
  40905. * If the gaze trackers color should be updated when selecting meshes
  40906. */
  40907. updateGazeTrackerColor: boolean;
  40908. /**
  40909. * The gaze tracking mesh corresponding to the left controller
  40910. */
  40911. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40912. /**
  40913. * The gaze tracking mesh corresponding to the right controller
  40914. */
  40915. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40916. /**
  40917. * If the ray of the gaze should be displayed.
  40918. */
  40919. /**
  40920. * Sets if the ray of the gaze should be displayed.
  40921. */
  40922. displayGaze: boolean;
  40923. /**
  40924. * If the ray of the LaserPointer should be displayed.
  40925. */
  40926. /**
  40927. * Sets if the ray of the LaserPointer should be displayed.
  40928. */
  40929. displayLaserPointer: boolean;
  40930. /**
  40931. * The deviceOrientationCamera used as the camera when not in VR.
  40932. */
  40933. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40934. /**
  40935. * Based on the current WebVR support, returns the current VR camera used.
  40936. */
  40937. readonly currentVRCamera: Nullable<Camera>;
  40938. /**
  40939. * The webVRCamera which is used when in VR.
  40940. */
  40941. readonly webVRCamera: WebVRFreeCamera;
  40942. /**
  40943. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40944. */
  40945. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40946. /**
  40947. * The html button that is used to trigger entering into VR.
  40948. */
  40949. readonly vrButton: Nullable<HTMLButtonElement>;
  40950. private readonly _teleportationRequestInitiated;
  40951. /**
  40952. * Defines wether or not Pointer lock should be requested when switching to
  40953. * full screen.
  40954. */
  40955. requestPointerLockOnFullScreen: boolean;
  40956. /**
  40957. * Instantiates a VRExperienceHelper.
  40958. * Helps to quickly add VR support to an existing scene.
  40959. * @param scene The scene the VRExperienceHelper belongs to.
  40960. * @param webVROptions Options to modify the vr experience helper's behavior.
  40961. */
  40962. constructor(scene: Scene,
  40963. /** Options to modify the vr experience helper's behavior. */
  40964. webVROptions?: VRExperienceHelperOptions);
  40965. private _onDefaultMeshLoaded;
  40966. private _onResize;
  40967. private _onFullscreenChange;
  40968. /**
  40969. * Gets a value indicating if we are currently in VR mode.
  40970. */
  40971. readonly isInVRMode: boolean;
  40972. private onVrDisplayPresentChange;
  40973. private onVRDisplayChanged;
  40974. private moveButtonToBottomRight;
  40975. private displayVRButton;
  40976. private updateButtonVisibility;
  40977. private _cachedAngularSensibility;
  40978. /**
  40979. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40980. * Otherwise, will use the fullscreen API.
  40981. */
  40982. enterVR(): void;
  40983. /**
  40984. * Attempt to exit VR, or fullscreen.
  40985. */
  40986. exitVR(): void;
  40987. /**
  40988. * The position of the vr experience helper.
  40989. */
  40990. /**
  40991. * Sets the position of the vr experience helper.
  40992. */
  40993. position: Vector3;
  40994. /**
  40995. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40996. */
  40997. enableInteractions(): void;
  40998. private readonly _noControllerIsActive;
  40999. private beforeRender;
  41000. private _isTeleportationFloor;
  41001. /**
  41002. * Adds a floor mesh to be used for teleportation.
  41003. * @param floorMesh the mesh to be used for teleportation.
  41004. */
  41005. addFloorMesh(floorMesh: Mesh): void;
  41006. /**
  41007. * Removes a floor mesh from being used for teleportation.
  41008. * @param floorMesh the mesh to be removed.
  41009. */
  41010. removeFloorMesh(floorMesh: Mesh): void;
  41011. /**
  41012. * Enables interactions and teleportation using the VR controllers and gaze.
  41013. * @param vrTeleportationOptions options to modify teleportation behavior.
  41014. */
  41015. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41016. private _onNewGamepadConnected;
  41017. private _tryEnableInteractionOnController;
  41018. private _onNewGamepadDisconnected;
  41019. private _enableInteractionOnController;
  41020. private _checkTeleportWithRay;
  41021. private _checkRotate;
  41022. private _checkTeleportBackwards;
  41023. private _enableTeleportationOnController;
  41024. private _createTeleportationCircles;
  41025. private _displayTeleportationTarget;
  41026. private _hideTeleportationTarget;
  41027. private _rotateCamera;
  41028. private _moveTeleportationSelectorTo;
  41029. private _workingVector;
  41030. private _workingQuaternion;
  41031. private _workingMatrix;
  41032. /**
  41033. * Teleports the users feet to the desired location
  41034. * @param location The location where the user's feet should be placed
  41035. */
  41036. teleportCamera(location: Vector3): void;
  41037. private _convertNormalToDirectionOfRay;
  41038. private _castRayAndSelectObject;
  41039. private _notifySelectedMeshUnselected;
  41040. /**
  41041. * Sets the color of the laser ray from the vr controllers.
  41042. * @param color new color for the ray.
  41043. */
  41044. changeLaserColor(color: Color3): void;
  41045. /**
  41046. * Sets the color of the ray from the vr headsets gaze.
  41047. * @param color new color for the ray.
  41048. */
  41049. changeGazeColor(color: Color3): void;
  41050. /**
  41051. * Exits VR and disposes of the vr experience helper
  41052. */
  41053. dispose(): void;
  41054. /**
  41055. * Gets the name of the VRExperienceHelper class
  41056. * @returns "VRExperienceHelper"
  41057. */
  41058. getClassName(): string;
  41059. }
  41060. }
  41061. declare module BABYLON {
  41062. /**
  41063. * Manages an XRSession to work with Babylon's engine
  41064. * @see https://doc.babylonjs.com/how_to/webxr
  41065. */
  41066. export class WebXRSessionManager implements IDisposable {
  41067. private scene;
  41068. /**
  41069. * Fires every time a new xrFrame arrives which can be used to update the camera
  41070. */
  41071. onXRFrameObservable: Observable<any>;
  41072. /**
  41073. * Fires when the xr session is ended either by the device or manually done
  41074. */
  41075. onXRSessionEnded: Observable<any>;
  41076. /**
  41077. * Underlying xr session
  41078. */
  41079. session: XRSession;
  41080. /**
  41081. * Type of reference space used when creating the session
  41082. */
  41083. referenceSpace: XRReferenceSpace;
  41084. /** @hidden */
  41085. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41086. /**
  41087. * Current XR frame
  41088. */
  41089. currentFrame: Nullable<XRFrame>;
  41090. private _xrNavigator;
  41091. private baseLayer;
  41092. /**
  41093. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41094. * @param scene The scene which the session should be created for
  41095. */
  41096. constructor(scene: Scene);
  41097. /**
  41098. * Initializes the manager
  41099. * After initialization enterXR can be called to start an XR session
  41100. * @returns Promise which resolves after it is initialized
  41101. */
  41102. initializeAsync(): Promise<void>;
  41103. /**
  41104. * Initializes an xr session
  41105. * @param xrSessionMode mode to initialize
  41106. * @returns a promise which will resolve once the session has been initialized
  41107. */
  41108. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41109. /**
  41110. * Sets the reference space on the xr session
  41111. * @param referenceSpace space to set
  41112. * @returns a promise that will resolve once the reference space has been set
  41113. */
  41114. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41115. /**
  41116. * Updates the render state of the session
  41117. * @param state state to set
  41118. * @returns a promise that resolves once the render state has been updated
  41119. */
  41120. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41121. /**
  41122. * Starts rendering to the xr layer
  41123. * @returns a promise that will resolve once rendering has started
  41124. */
  41125. startRenderingToXRAsync(): Promise<void>;
  41126. /**
  41127. * Stops the xrSession and restores the renderloop
  41128. * @returns Promise which resolves after it exits XR
  41129. */
  41130. exitXRAsync(): Promise<unknown>;
  41131. /**
  41132. * Checks if a session would be supported for the creation options specified
  41133. * @param sessionMode session mode to check if supported eg. immersive-vr
  41134. * @returns true if supported
  41135. */
  41136. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41137. /**
  41138. * @hidden
  41139. * Converts the render layer of xrSession to a render target
  41140. * @param session session to create render target for
  41141. * @param scene scene the new render target should be created for
  41142. */
  41143. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41144. /**
  41145. * Disposes of the session manager
  41146. */
  41147. dispose(): void;
  41148. }
  41149. }
  41150. declare module BABYLON {
  41151. /**
  41152. * WebXR Camera which holds the views for the xrSession
  41153. * @see https://doc.babylonjs.com/how_to/webxr
  41154. */
  41155. export class WebXRCamera extends FreeCamera {
  41156. private static _TmpMatrix;
  41157. /**
  41158. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41159. * @param name the name of the camera
  41160. * @param scene the scene to add the camera to
  41161. */
  41162. constructor(name: string, scene: Scene);
  41163. private _updateNumberOfRigCameras;
  41164. /** @hidden */
  41165. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41166. /**
  41167. * Updates the cameras position from the current pose information of the XR session
  41168. * @param xrSessionManager the session containing pose information
  41169. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41170. */
  41171. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41172. }
  41173. }
  41174. declare module BABYLON {
  41175. /**
  41176. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41177. */
  41178. export class WebXRManagedOutputCanvas implements IDisposable {
  41179. private helper;
  41180. private _canvas;
  41181. /**
  41182. * xrpresent context of the canvas which can be used to display/mirror xr content
  41183. */
  41184. canvasContext: WebGLRenderingContext;
  41185. /**
  41186. * xr layer for the canvas
  41187. */
  41188. xrLayer: Nullable<XRWebGLLayer>;
  41189. /**
  41190. * Initializes the xr layer for the session
  41191. * @param xrSession xr session
  41192. * @returns a promise that will resolve once the XR Layer has been created
  41193. */
  41194. initializeXRLayerAsync(xrSession: any): any;
  41195. /**
  41196. * Initializes the canvas to be added/removed upon entering/exiting xr
  41197. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41198. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41199. */
  41200. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41201. /**
  41202. * Disposes of the object
  41203. */
  41204. dispose(): void;
  41205. private _setManagedOutputCanvas;
  41206. private _addCanvas;
  41207. private _removeCanvas;
  41208. }
  41209. }
  41210. declare module BABYLON {
  41211. /**
  41212. * States of the webXR experience
  41213. */
  41214. export enum WebXRState {
  41215. /**
  41216. * Transitioning to being in XR mode
  41217. */
  41218. ENTERING_XR = 0,
  41219. /**
  41220. * Transitioning to non XR mode
  41221. */
  41222. EXITING_XR = 1,
  41223. /**
  41224. * In XR mode and presenting
  41225. */
  41226. IN_XR = 2,
  41227. /**
  41228. * Not entered XR mode
  41229. */
  41230. NOT_IN_XR = 3
  41231. }
  41232. /**
  41233. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41234. * @see https://doc.babylonjs.com/how_to/webxr
  41235. */
  41236. export class WebXRExperienceHelper implements IDisposable {
  41237. private scene;
  41238. /**
  41239. * 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
  41240. */
  41241. container: AbstractMesh;
  41242. /**
  41243. * Camera used to render xr content
  41244. */
  41245. camera: WebXRCamera;
  41246. /**
  41247. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41248. */
  41249. state: WebXRState;
  41250. private _setState;
  41251. private static _TmpVector;
  41252. /**
  41253. * Fires when the state of the experience helper has changed
  41254. */
  41255. onStateChangedObservable: Observable<WebXRState>;
  41256. /** Session manager used to keep track of xr session */
  41257. sessionManager: WebXRSessionManager;
  41258. private _nonVRCamera;
  41259. private _originalSceneAutoClear;
  41260. private _supported;
  41261. /**
  41262. * Creates the experience helper
  41263. * @param scene the scene to attach the experience helper to
  41264. * @returns a promise for the experience helper
  41265. */
  41266. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41267. /**
  41268. * Creates a WebXRExperienceHelper
  41269. * @param scene The scene the helper should be created in
  41270. */
  41271. private constructor();
  41272. /**
  41273. * Exits XR mode and returns the scene to its original state
  41274. * @returns promise that resolves after xr mode has exited
  41275. */
  41276. exitXRAsync(): Promise<unknown>;
  41277. /**
  41278. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41279. * @param sessionCreationOptions options for the XR session
  41280. * @param referenceSpaceType frame of reference of the XR session
  41281. * @param outputCanvas the output canvas that will be used to enter XR mode
  41282. * @returns promise that resolves after xr mode has entered
  41283. */
  41284. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41285. /**
  41286. * Updates the global position of the camera by moving the camera's container
  41287. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41288. * @param position The desired global position of the camera
  41289. */
  41290. setPositionOfCameraUsingContainer(position: Vector3): void;
  41291. /**
  41292. * Rotates the xr camera by rotating the camera's container around the camera's position
  41293. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41294. * @param rotation the desired quaternion rotation to apply to the camera
  41295. */
  41296. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41297. /**
  41298. * Disposes of the experience helper
  41299. */
  41300. dispose(): void;
  41301. }
  41302. }
  41303. declare module BABYLON {
  41304. /**
  41305. * Button which can be used to enter a different mode of XR
  41306. */
  41307. export class WebXREnterExitUIButton {
  41308. /** button element */
  41309. element: HTMLElement;
  41310. /** XR initialization options for the button */
  41311. sessionMode: XRSessionMode;
  41312. /** Reference space type */
  41313. referenceSpaceType: XRReferenceSpaceType;
  41314. /**
  41315. * Creates a WebXREnterExitUIButton
  41316. * @param element button element
  41317. * @param sessionMode XR initialization session mode
  41318. * @param referenceSpaceType the type of reference space to be used
  41319. */
  41320. constructor(
  41321. /** button element */
  41322. element: HTMLElement,
  41323. /** XR initialization options for the button */
  41324. sessionMode: XRSessionMode,
  41325. /** Reference space type */
  41326. referenceSpaceType: XRReferenceSpaceType);
  41327. /**
  41328. * Overwritable function which can be used to update the button's visuals when the state changes
  41329. * @param activeButton the current active button in the UI
  41330. */
  41331. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41332. }
  41333. /**
  41334. * Options to create the webXR UI
  41335. */
  41336. export class WebXREnterExitUIOptions {
  41337. /**
  41338. * Context to enter xr with
  41339. */
  41340. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41341. /**
  41342. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41343. */
  41344. customButtons?: Array<WebXREnterExitUIButton>;
  41345. }
  41346. /**
  41347. * UI to allow the user to enter/exit XR mode
  41348. */
  41349. export class WebXREnterExitUI implements IDisposable {
  41350. private scene;
  41351. private _overlay;
  41352. private _buttons;
  41353. private _activeButton;
  41354. /**
  41355. * Fired every time the active button is changed.
  41356. *
  41357. * When xr is entered via a button that launches xr that button will be the callback parameter
  41358. *
  41359. * When exiting xr the callback parameter will be null)
  41360. */
  41361. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41362. /**
  41363. * Creates UI to allow the user to enter/exit XR mode
  41364. * @param scene the scene to add the ui to
  41365. * @param helper the xr experience helper to enter/exit xr with
  41366. * @param options options to configure the UI
  41367. * @returns the created ui
  41368. */
  41369. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41370. private constructor();
  41371. private _updateButtons;
  41372. /**
  41373. * Disposes of the object
  41374. */
  41375. dispose(): void;
  41376. }
  41377. }
  41378. declare module BABYLON {
  41379. /**
  41380. * Represents an XR input
  41381. */
  41382. export class WebXRController {
  41383. private scene;
  41384. /** The underlying input source for the controller */
  41385. inputSource: XRInputSource;
  41386. private parentContainer;
  41387. /**
  41388. * 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
  41389. */
  41390. grip?: AbstractMesh;
  41391. /**
  41392. * Pointer which can be used to select objects or attach a visible laser to
  41393. */
  41394. pointer: AbstractMesh;
  41395. /**
  41396. * Event that fires when the controller is removed/disposed
  41397. */
  41398. onDisposeObservable: Observable<{}>;
  41399. private _tmpMatrix;
  41400. private _tmpQuaternion;
  41401. private _tmpVector;
  41402. /**
  41403. * Creates the controller
  41404. * @see https://doc.babylonjs.com/how_to/webxr
  41405. * @param scene the scene which the controller should be associated to
  41406. * @param inputSource the underlying input source for the controller
  41407. * @param parentContainer parent that the controller meshes should be children of
  41408. */
  41409. constructor(scene: Scene,
  41410. /** The underlying input source for the controller */
  41411. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41412. /**
  41413. * Updates the controller pose based on the given XRFrame
  41414. * @param xrFrame xr frame to update the pose with
  41415. * @param referenceSpace reference space to use
  41416. */
  41417. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41418. /**
  41419. * Gets a world space ray coming from the controller
  41420. * @param result the resulting ray
  41421. */
  41422. getWorldPointerRayToRef(result: Ray): void;
  41423. /**
  41424. * Disposes of the object
  41425. */
  41426. dispose(): void;
  41427. }
  41428. }
  41429. declare module BABYLON {
  41430. /**
  41431. * XR input used to track XR inputs such as controllers/rays
  41432. */
  41433. export class WebXRInput implements IDisposable {
  41434. /**
  41435. * Base experience the input listens to
  41436. */
  41437. baseExperience: WebXRExperienceHelper;
  41438. /**
  41439. * XR controllers being tracked
  41440. */
  41441. controllers: Array<WebXRController>;
  41442. private _frameObserver;
  41443. private _stateObserver;
  41444. /**
  41445. * Event when a controller has been connected/added
  41446. */
  41447. onControllerAddedObservable: Observable<WebXRController>;
  41448. /**
  41449. * Event when a controller has been removed/disconnected
  41450. */
  41451. onControllerRemovedObservable: Observable<WebXRController>;
  41452. /**
  41453. * Initializes the WebXRInput
  41454. * @param baseExperience experience helper which the input should be created for
  41455. */
  41456. constructor(
  41457. /**
  41458. * Base experience the input listens to
  41459. */
  41460. baseExperience: WebXRExperienceHelper);
  41461. private _onInputSourcesChange;
  41462. private _addAndRemoveControllers;
  41463. /**
  41464. * Disposes of the object
  41465. */
  41466. dispose(): void;
  41467. }
  41468. }
  41469. declare module BABYLON {
  41470. /**
  41471. * Enables teleportation
  41472. */
  41473. export class WebXRControllerTeleportation {
  41474. private _teleportationFillColor;
  41475. private _teleportationBorderColor;
  41476. private _tmpRay;
  41477. private _tmpVector;
  41478. /**
  41479. * Creates a WebXRControllerTeleportation
  41480. * @param input input manager to add teleportation to
  41481. * @param floorMeshes floormeshes which can be teleported to
  41482. */
  41483. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41484. }
  41485. }
  41486. declare module BABYLON {
  41487. /**
  41488. * Handles pointer input automatically for the pointer of XR controllers
  41489. */
  41490. export class WebXRControllerPointerSelection {
  41491. private static _idCounter;
  41492. private _tmpRay;
  41493. /**
  41494. * Creates a WebXRControllerPointerSelection
  41495. * @param input input manager to setup pointer selection
  41496. */
  41497. constructor(input: WebXRInput);
  41498. private _convertNormalToDirectionOfRay;
  41499. private _updatePointerDistance;
  41500. }
  41501. }
  41502. declare module BABYLON {
  41503. /**
  41504. * Class used to represent data loading progression
  41505. */
  41506. export class SceneLoaderProgressEvent {
  41507. /** defines if data length to load can be evaluated */
  41508. readonly lengthComputable: boolean;
  41509. /** defines the loaded data length */
  41510. readonly loaded: number;
  41511. /** defines the data length to load */
  41512. readonly total: number;
  41513. /**
  41514. * Create a new progress event
  41515. * @param lengthComputable defines if data length to load can be evaluated
  41516. * @param loaded defines the loaded data length
  41517. * @param total defines the data length to load
  41518. */
  41519. constructor(
  41520. /** defines if data length to load can be evaluated */
  41521. lengthComputable: boolean,
  41522. /** defines the loaded data length */
  41523. loaded: number,
  41524. /** defines the data length to load */
  41525. total: number);
  41526. /**
  41527. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41528. * @param event defines the source event
  41529. * @returns a new SceneLoaderProgressEvent
  41530. */
  41531. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41532. }
  41533. /**
  41534. * Interface used by SceneLoader plugins to define supported file extensions
  41535. */
  41536. export interface ISceneLoaderPluginExtensions {
  41537. /**
  41538. * Defines the list of supported extensions
  41539. */
  41540. [extension: string]: {
  41541. isBinary: boolean;
  41542. };
  41543. }
  41544. /**
  41545. * Interface used by SceneLoader plugin factory
  41546. */
  41547. export interface ISceneLoaderPluginFactory {
  41548. /**
  41549. * Defines the name of the factory
  41550. */
  41551. name: string;
  41552. /**
  41553. * Function called to create a new plugin
  41554. * @return the new plugin
  41555. */
  41556. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41557. /**
  41558. * Boolean indicating if the plugin can direct load specific data
  41559. */
  41560. canDirectLoad?: (data: string) => boolean;
  41561. }
  41562. /**
  41563. * Interface used to define a SceneLoader plugin
  41564. */
  41565. export interface ISceneLoaderPlugin {
  41566. /**
  41567. * The friendly name of this plugin.
  41568. */
  41569. name: string;
  41570. /**
  41571. * The file extensions supported by this plugin.
  41572. */
  41573. extensions: string | ISceneLoaderPluginExtensions;
  41574. /**
  41575. * Import meshes into a scene.
  41576. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41577. * @param scene The scene to import into
  41578. * @param data The data to import
  41579. * @param rootUrl The root url for scene and resources
  41580. * @param meshes The meshes array to import into
  41581. * @param particleSystems The particle systems array to import into
  41582. * @param skeletons The skeletons array to import into
  41583. * @param onError The callback when import fails
  41584. * @returns True if successful or false otherwise
  41585. */
  41586. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41587. /**
  41588. * Load into a scene.
  41589. * @param scene The scene to load into
  41590. * @param data The data to import
  41591. * @param rootUrl The root url for scene and resources
  41592. * @param onError The callback when import fails
  41593. * @returns true if successful or false otherwise
  41594. */
  41595. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41596. /**
  41597. * The callback that returns true if the data can be directly loaded.
  41598. */
  41599. canDirectLoad?: (data: string) => boolean;
  41600. /**
  41601. * The callback that allows custom handling of the root url based on the response url.
  41602. */
  41603. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41604. /**
  41605. * Load into an asset container.
  41606. * @param scene The scene to load into
  41607. * @param data The data to import
  41608. * @param rootUrl The root url for scene and resources
  41609. * @param onError The callback when import fails
  41610. * @returns The loaded asset container
  41611. */
  41612. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41613. }
  41614. /**
  41615. * Interface used to define an async SceneLoader plugin
  41616. */
  41617. export interface ISceneLoaderPluginAsync {
  41618. /**
  41619. * The friendly name of this plugin.
  41620. */
  41621. name: string;
  41622. /**
  41623. * The file extensions supported by this plugin.
  41624. */
  41625. extensions: string | ISceneLoaderPluginExtensions;
  41626. /**
  41627. * Import meshes into a scene.
  41628. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41629. * @param scene The scene to import into
  41630. * @param data The data to import
  41631. * @param rootUrl The root url for scene and resources
  41632. * @param onProgress The callback when the load progresses
  41633. * @param fileName Defines the name of the file to load
  41634. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41635. */
  41636. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41637. meshes: AbstractMesh[];
  41638. particleSystems: IParticleSystem[];
  41639. skeletons: Skeleton[];
  41640. animationGroups: AnimationGroup[];
  41641. }>;
  41642. /**
  41643. * Load into a scene.
  41644. * @param scene The scene to load into
  41645. * @param data The data to import
  41646. * @param rootUrl The root url for scene and resources
  41647. * @param onProgress The callback when the load progresses
  41648. * @param fileName Defines the name of the file to load
  41649. * @returns Nothing
  41650. */
  41651. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41652. /**
  41653. * The callback that returns true if the data can be directly loaded.
  41654. */
  41655. canDirectLoad?: (data: string) => boolean;
  41656. /**
  41657. * The callback that allows custom handling of the root url based on the response url.
  41658. */
  41659. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41660. /**
  41661. * Load into an asset container.
  41662. * @param scene The scene to load into
  41663. * @param data The data to import
  41664. * @param rootUrl The root url for scene and resources
  41665. * @param onProgress The callback when the load progresses
  41666. * @param fileName Defines the name of the file to load
  41667. * @returns The loaded asset container
  41668. */
  41669. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41670. }
  41671. /**
  41672. * Class used to load scene from various file formats using registered plugins
  41673. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41674. */
  41675. export class SceneLoader {
  41676. /**
  41677. * No logging while loading
  41678. */
  41679. static readonly NO_LOGGING: number;
  41680. /**
  41681. * Minimal logging while loading
  41682. */
  41683. static readonly MINIMAL_LOGGING: number;
  41684. /**
  41685. * Summary logging while loading
  41686. */
  41687. static readonly SUMMARY_LOGGING: number;
  41688. /**
  41689. * Detailled logging while loading
  41690. */
  41691. static readonly DETAILED_LOGGING: number;
  41692. /**
  41693. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41694. */
  41695. static ForceFullSceneLoadingForIncremental: boolean;
  41696. /**
  41697. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41698. */
  41699. static ShowLoadingScreen: boolean;
  41700. /**
  41701. * Defines the current logging level (while loading the scene)
  41702. * @ignorenaming
  41703. */
  41704. static loggingLevel: number;
  41705. /**
  41706. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41707. */
  41708. static CleanBoneMatrixWeights: boolean;
  41709. /**
  41710. * Event raised when a plugin is used to load a scene
  41711. */
  41712. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41713. private static _registeredPlugins;
  41714. private static _getDefaultPlugin;
  41715. private static _getPluginForExtension;
  41716. private static _getPluginForDirectLoad;
  41717. private static _getPluginForFilename;
  41718. private static _getDirectLoad;
  41719. private static _loadData;
  41720. private static _getFileInfo;
  41721. /**
  41722. * Gets a plugin that can load the given extension
  41723. * @param extension defines the extension to load
  41724. * @returns a plugin or null if none works
  41725. */
  41726. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41727. /**
  41728. * Gets a boolean indicating that the given extension can be loaded
  41729. * @param extension defines the extension to load
  41730. * @returns true if the extension is supported
  41731. */
  41732. static IsPluginForExtensionAvailable(extension: string): boolean;
  41733. /**
  41734. * Adds a new plugin to the list of registered plugins
  41735. * @param plugin defines the plugin to add
  41736. */
  41737. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41738. /**
  41739. * Import meshes into a scene
  41740. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41741. * @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)
  41742. * @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)
  41743. * @param scene the instance of BABYLON.Scene to append to
  41744. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41745. * @param onProgress a callback with a progress event for each file being loaded
  41746. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41747. * @param pluginExtension the extension used to determine the plugin
  41748. * @returns The loaded plugin
  41749. */
  41750. 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>;
  41751. /**
  41752. * Import meshes into a scene
  41753. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41754. * @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)
  41755. * @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)
  41756. * @param scene the instance of BABYLON.Scene to append to
  41757. * @param onProgress a callback with a progress event for each file being loaded
  41758. * @param pluginExtension the extension used to determine the plugin
  41759. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41760. */
  41761. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41762. meshes: AbstractMesh[];
  41763. particleSystems: IParticleSystem[];
  41764. skeletons: Skeleton[];
  41765. animationGroups: AnimationGroup[];
  41766. }>;
  41767. /**
  41768. * Load a scene
  41769. * @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)
  41770. * @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)
  41771. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41772. * @param onSuccess a callback with the scene when import succeeds
  41773. * @param onProgress a callback with a progress event for each file being loaded
  41774. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41775. * @param pluginExtension the extension used to determine the plugin
  41776. * @returns The loaded plugin
  41777. */
  41778. 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>;
  41779. /**
  41780. * Load a scene
  41781. * @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)
  41782. * @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)
  41783. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41784. * @param onProgress a callback with a progress event for each file being loaded
  41785. * @param pluginExtension the extension used to determine the plugin
  41786. * @returns The loaded scene
  41787. */
  41788. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41789. /**
  41790. * Append a scene
  41791. * @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)
  41792. * @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)
  41793. * @param scene is the instance of BABYLON.Scene to append to
  41794. * @param onSuccess a callback with the scene when import succeeds
  41795. * @param onProgress a callback with a progress event for each file being loaded
  41796. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41797. * @param pluginExtension the extension used to determine the plugin
  41798. * @returns The loaded plugin
  41799. */
  41800. 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>;
  41801. /**
  41802. * Append a scene
  41803. * @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)
  41804. * @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)
  41805. * @param scene is the instance of BABYLON.Scene to append to
  41806. * @param onProgress a callback with a progress event for each file being loaded
  41807. * @param pluginExtension the extension used to determine the plugin
  41808. * @returns The given scene
  41809. */
  41810. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41811. /**
  41812. * Load a scene into an asset container
  41813. * @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)
  41814. * @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)
  41815. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41816. * @param onSuccess a callback with the scene when import succeeds
  41817. * @param onProgress a callback with a progress event for each file being loaded
  41818. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41819. * @param pluginExtension the extension used to determine the plugin
  41820. * @returns The loaded plugin
  41821. */
  41822. 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>;
  41823. /**
  41824. * Load a scene into an asset container
  41825. * @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)
  41826. * @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)
  41827. * @param scene is the instance of Scene to append to
  41828. * @param onProgress a callback with a progress event for each file being loaded
  41829. * @param pluginExtension the extension used to determine the plugin
  41830. * @returns The loaded asset container
  41831. */
  41832. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Generic Controller
  41838. */
  41839. export class GenericController extends WebVRController {
  41840. /**
  41841. * Base Url for the controller model.
  41842. */
  41843. static readonly MODEL_BASE_URL: string;
  41844. /**
  41845. * File name for the controller model.
  41846. */
  41847. static readonly MODEL_FILENAME: string;
  41848. /**
  41849. * Creates a new GenericController from a gamepad
  41850. * @param vrGamepad the gamepad that the controller should be created from
  41851. */
  41852. constructor(vrGamepad: any);
  41853. /**
  41854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41855. * @param scene scene in which to add meshes
  41856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41857. */
  41858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41859. /**
  41860. * Called once for each button that changed state since the last frame
  41861. * @param buttonIdx Which button index changed
  41862. * @param state New state of the button
  41863. * @param changes Which properties on the state changed since last frame
  41864. */
  41865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41866. }
  41867. }
  41868. declare module BABYLON {
  41869. /**
  41870. * Defines the WindowsMotionController object that the state of the windows motion controller
  41871. */
  41872. export class WindowsMotionController extends WebVRController {
  41873. /**
  41874. * The base url used to load the left and right controller models
  41875. */
  41876. static MODEL_BASE_URL: string;
  41877. /**
  41878. * The name of the left controller model file
  41879. */
  41880. static MODEL_LEFT_FILENAME: string;
  41881. /**
  41882. * The name of the right controller model file
  41883. */
  41884. static MODEL_RIGHT_FILENAME: string;
  41885. /**
  41886. * The controller name prefix for this controller type
  41887. */
  41888. static readonly GAMEPAD_ID_PREFIX: string;
  41889. /**
  41890. * The controller id pattern for this controller type
  41891. */
  41892. private static readonly GAMEPAD_ID_PATTERN;
  41893. private _loadedMeshInfo;
  41894. private readonly _mapping;
  41895. /**
  41896. * Fired when the trackpad on this controller is clicked
  41897. */
  41898. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41899. /**
  41900. * Fired when the trackpad on this controller is modified
  41901. */
  41902. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41903. /**
  41904. * The current x and y values of this controller's trackpad
  41905. */
  41906. trackpad: StickValues;
  41907. /**
  41908. * Creates a new WindowsMotionController from a gamepad
  41909. * @param vrGamepad the gamepad that the controller should be created from
  41910. */
  41911. constructor(vrGamepad: any);
  41912. /**
  41913. * Fired when the trigger on this controller is modified
  41914. */
  41915. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41916. /**
  41917. * Fired when the menu button on this controller is modified
  41918. */
  41919. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41920. /**
  41921. * Fired when the grip button on this controller is modified
  41922. */
  41923. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41924. /**
  41925. * Fired when the thumbstick button on this controller is modified
  41926. */
  41927. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41928. /**
  41929. * Fired when the touchpad button on this controller is modified
  41930. */
  41931. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41932. /**
  41933. * Fired when the touchpad values on this controller are modified
  41934. */
  41935. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41936. private _updateTrackpad;
  41937. /**
  41938. * Called once per frame by the engine.
  41939. */
  41940. update(): void;
  41941. /**
  41942. * Called once for each button that changed state since the last frame
  41943. * @param buttonIdx Which button index changed
  41944. * @param state New state of the button
  41945. * @param changes Which properties on the state changed since last frame
  41946. */
  41947. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41948. /**
  41949. * Moves the buttons on the controller mesh based on their current state
  41950. * @param buttonName the name of the button to move
  41951. * @param buttonValue the value of the button which determines the buttons new position
  41952. */
  41953. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41954. /**
  41955. * Moves the axis on the controller mesh based on its current state
  41956. * @param axis the index of the axis
  41957. * @param axisValue the value of the axis which determines the meshes new position
  41958. * @hidden
  41959. */
  41960. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41961. /**
  41962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41963. * @param scene scene in which to add meshes
  41964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41965. */
  41966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41967. /**
  41968. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41969. * can be transformed by button presses and axes values, based on this._mapping.
  41970. *
  41971. * @param scene scene in which the meshes exist
  41972. * @param meshes list of meshes that make up the controller model to process
  41973. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41974. */
  41975. private processModel;
  41976. private createMeshInfo;
  41977. /**
  41978. * Gets the ray of the controller in the direction the controller is pointing
  41979. * @param length the length the resulting ray should be
  41980. * @returns a ray in the direction the controller is pointing
  41981. */
  41982. getForwardRay(length?: number): Ray;
  41983. /**
  41984. * Disposes of the controller
  41985. */
  41986. dispose(): void;
  41987. }
  41988. }
  41989. declare module BABYLON {
  41990. /**
  41991. * Oculus Touch Controller
  41992. */
  41993. export class OculusTouchController extends WebVRController {
  41994. /**
  41995. * Base Url for the controller model.
  41996. */
  41997. static MODEL_BASE_URL: string;
  41998. /**
  41999. * File name for the left controller model.
  42000. */
  42001. static MODEL_LEFT_FILENAME: string;
  42002. /**
  42003. * File name for the right controller model.
  42004. */
  42005. static MODEL_RIGHT_FILENAME: string;
  42006. /**
  42007. * Base Url for the Quest controller model.
  42008. */
  42009. static QUEST_MODEL_BASE_URL: string;
  42010. /**
  42011. * @hidden
  42012. * If the controllers are running on a device that needs the updated Quest controller models
  42013. */
  42014. static _IsQuest: boolean;
  42015. /**
  42016. * Fired when the secondary trigger on this controller is modified
  42017. */
  42018. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42019. /**
  42020. * Fired when the thumb rest on this controller is modified
  42021. */
  42022. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42023. /**
  42024. * Creates a new OculusTouchController from a gamepad
  42025. * @param vrGamepad the gamepad that the controller should be created from
  42026. */
  42027. constructor(vrGamepad: any);
  42028. /**
  42029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42030. * @param scene scene in which to add meshes
  42031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42032. */
  42033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42034. /**
  42035. * Fired when the A button on this controller is modified
  42036. */
  42037. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42038. /**
  42039. * Fired when the B button on this controller is modified
  42040. */
  42041. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42042. /**
  42043. * Fired when the X button on this controller is modified
  42044. */
  42045. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42046. /**
  42047. * Fired when the Y button on this controller is modified
  42048. */
  42049. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42050. /**
  42051. * Called once for each button that changed state since the last frame
  42052. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42053. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42054. * 2) secondary trigger (same)
  42055. * 3) A (right) X (left), touch, pressed = value
  42056. * 4) B / Y
  42057. * 5) thumb rest
  42058. * @param buttonIdx Which button index changed
  42059. * @param state New state of the button
  42060. * @param changes Which properties on the state changed since last frame
  42061. */
  42062. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42063. }
  42064. }
  42065. declare module BABYLON {
  42066. /**
  42067. * Vive Controller
  42068. */
  42069. export class ViveController extends WebVRController {
  42070. /**
  42071. * Base Url for the controller model.
  42072. */
  42073. static MODEL_BASE_URL: string;
  42074. /**
  42075. * File name for the controller model.
  42076. */
  42077. static MODEL_FILENAME: string;
  42078. /**
  42079. * Creates a new ViveController from a gamepad
  42080. * @param vrGamepad the gamepad that the controller should be created from
  42081. */
  42082. constructor(vrGamepad: any);
  42083. /**
  42084. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42085. * @param scene scene in which to add meshes
  42086. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42087. */
  42088. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42089. /**
  42090. * Fired when the left button on this controller is modified
  42091. */
  42092. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42093. /**
  42094. * Fired when the right button on this controller is modified
  42095. */
  42096. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42097. /**
  42098. * Fired when the menu button on this controller is modified
  42099. */
  42100. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42101. /**
  42102. * Called once for each button that changed state since the last frame
  42103. * Vive mapping:
  42104. * 0: touchpad
  42105. * 1: trigger
  42106. * 2: left AND right buttons
  42107. * 3: menu button
  42108. * @param buttonIdx Which button index changed
  42109. * @param state New state of the button
  42110. * @param changes Which properties on the state changed since last frame
  42111. */
  42112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42118. */
  42119. export class WebXRControllerModelLoader {
  42120. /**
  42121. * Creates the WebXRControllerModelLoader
  42122. * @param input xr input that creates the controllers
  42123. */
  42124. constructor(input: WebXRInput);
  42125. }
  42126. }
  42127. declare module BABYLON {
  42128. /**
  42129. * Contains an array of blocks representing the octree
  42130. */
  42131. export interface IOctreeContainer<T> {
  42132. /**
  42133. * Blocks within the octree
  42134. */
  42135. blocks: Array<OctreeBlock<T>>;
  42136. }
  42137. /**
  42138. * Class used to store a cell in an octree
  42139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42140. */
  42141. export class OctreeBlock<T> {
  42142. /**
  42143. * Gets the content of the current block
  42144. */
  42145. entries: T[];
  42146. /**
  42147. * Gets the list of block children
  42148. */
  42149. blocks: Array<OctreeBlock<T>>;
  42150. private _depth;
  42151. private _maxDepth;
  42152. private _capacity;
  42153. private _minPoint;
  42154. private _maxPoint;
  42155. private _boundingVectors;
  42156. private _creationFunc;
  42157. /**
  42158. * Creates a new block
  42159. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42160. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42161. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42162. * @param depth defines the current depth of this block in the octree
  42163. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42164. * @param creationFunc defines a callback to call when an element is added to the block
  42165. */
  42166. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42167. /**
  42168. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42169. */
  42170. readonly capacity: number;
  42171. /**
  42172. * Gets the minimum vector (in world space) of the block's bounding box
  42173. */
  42174. readonly minPoint: Vector3;
  42175. /**
  42176. * Gets the maximum vector (in world space) of the block's bounding box
  42177. */
  42178. readonly maxPoint: Vector3;
  42179. /**
  42180. * Add a new element to this block
  42181. * @param entry defines the element to add
  42182. */
  42183. addEntry(entry: T): void;
  42184. /**
  42185. * Remove an element from this block
  42186. * @param entry defines the element to remove
  42187. */
  42188. removeEntry(entry: T): void;
  42189. /**
  42190. * Add an array of elements to this block
  42191. * @param entries defines the array of elements to add
  42192. */
  42193. addEntries(entries: T[]): void;
  42194. /**
  42195. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42196. * @param frustumPlanes defines the frustum planes to test
  42197. * @param selection defines the array to store current content if selection is positive
  42198. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42199. */
  42200. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42201. /**
  42202. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42203. * @param sphereCenter defines the bounding sphere center
  42204. * @param sphereRadius defines the bounding sphere radius
  42205. * @param selection defines the array to store current content if selection is positive
  42206. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42207. */
  42208. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42209. /**
  42210. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42211. * @param ray defines the ray to test with
  42212. * @param selection defines the array to store current content if selection is positive
  42213. */
  42214. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42215. /**
  42216. * Subdivide the content into child blocks (this block will then be empty)
  42217. */
  42218. createInnerBlocks(): void;
  42219. /**
  42220. * @hidden
  42221. */
  42222. 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;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /**
  42227. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42228. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42229. */
  42230. export class Octree<T> {
  42231. /** 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.) */
  42232. maxDepth: number;
  42233. /**
  42234. * Blocks within the octree containing objects
  42235. */
  42236. blocks: Array<OctreeBlock<T>>;
  42237. /**
  42238. * Content stored in the octree
  42239. */
  42240. dynamicContent: T[];
  42241. private _maxBlockCapacity;
  42242. private _selectionContent;
  42243. private _creationFunc;
  42244. /**
  42245. * Creates a octree
  42246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42247. * @param creationFunc function to be used to instatiate the octree
  42248. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42249. * @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.)
  42250. */
  42251. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42252. /** 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.) */
  42253. maxDepth?: number);
  42254. /**
  42255. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42256. * @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);
  42257. * @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);
  42258. * @param entries meshes to be added to the octree blocks
  42259. */
  42260. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42261. /**
  42262. * Adds a mesh to the octree
  42263. * @param entry Mesh to add to the octree
  42264. */
  42265. addMesh(entry: T): void;
  42266. /**
  42267. * Remove an element from the octree
  42268. * @param entry defines the element to remove
  42269. */
  42270. removeMesh(entry: T): void;
  42271. /**
  42272. * Selects an array of meshes within the frustum
  42273. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42274. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42275. * @returns array of meshes within the frustum
  42276. */
  42277. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42278. /**
  42279. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42280. * @param sphereCenter defines the bounding sphere center
  42281. * @param sphereRadius defines the bounding sphere radius
  42282. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42283. * @returns an array of objects that intersect the sphere
  42284. */
  42285. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42286. /**
  42287. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42288. * @param ray defines the ray to test with
  42289. * @returns array of intersected objects
  42290. */
  42291. intersectsRay(ray: Ray): SmartArray<T>;
  42292. /**
  42293. * Adds a mesh into the octree block if it intersects the block
  42294. */
  42295. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42296. /**
  42297. * Adds a submesh into the octree block if it intersects the block
  42298. */
  42299. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42300. }
  42301. }
  42302. declare module BABYLON {
  42303. interface Scene {
  42304. /**
  42305. * @hidden
  42306. * Backing Filed
  42307. */
  42308. _selectionOctree: Octree<AbstractMesh>;
  42309. /**
  42310. * Gets the octree used to boost mesh selection (picking)
  42311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42312. */
  42313. selectionOctree: Octree<AbstractMesh>;
  42314. /**
  42315. * Creates or updates the octree used to boost selection (picking)
  42316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42317. * @param maxCapacity defines the maximum capacity per leaf
  42318. * @param maxDepth defines the maximum depth of the octree
  42319. * @returns an octree of AbstractMesh
  42320. */
  42321. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42322. }
  42323. interface AbstractMesh {
  42324. /**
  42325. * @hidden
  42326. * Backing Field
  42327. */
  42328. _submeshesOctree: Octree<SubMesh>;
  42329. /**
  42330. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42331. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42332. * @param maxCapacity defines the maximum size of each block (64 by default)
  42333. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42334. * @returns the new octree
  42335. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42336. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42337. */
  42338. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42339. }
  42340. /**
  42341. * Defines the octree scene component responsible to manage any octrees
  42342. * in a given scene.
  42343. */
  42344. export class OctreeSceneComponent {
  42345. /**
  42346. * The component name help to identify the component in the list of scene components.
  42347. */
  42348. readonly name: string;
  42349. /**
  42350. * The scene the component belongs to.
  42351. */
  42352. scene: Scene;
  42353. /**
  42354. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42355. */
  42356. readonly checksIsEnabled: boolean;
  42357. /**
  42358. * Creates a new instance of the component for the given scene
  42359. * @param scene Defines the scene to register the component in
  42360. */
  42361. constructor(scene: Scene);
  42362. /**
  42363. * Registers the component in a given scene
  42364. */
  42365. register(): void;
  42366. /**
  42367. * Return the list of active meshes
  42368. * @returns the list of active meshes
  42369. */
  42370. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42371. /**
  42372. * Return the list of active sub meshes
  42373. * @param mesh The mesh to get the candidates sub meshes from
  42374. * @returns the list of active sub meshes
  42375. */
  42376. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42377. private _tempRay;
  42378. /**
  42379. * Return the list of sub meshes intersecting with a given local ray
  42380. * @param mesh defines the mesh to find the submesh for
  42381. * @param localRay defines the ray in local space
  42382. * @returns the list of intersecting sub meshes
  42383. */
  42384. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42385. /**
  42386. * Return the list of sub meshes colliding with a collider
  42387. * @param mesh defines the mesh to find the submesh for
  42388. * @param collider defines the collider to evaluate the collision against
  42389. * @returns the list of colliding sub meshes
  42390. */
  42391. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42392. /**
  42393. * Rebuilds the elements related to this component in case of
  42394. * context lost for instance.
  42395. */
  42396. rebuild(): void;
  42397. /**
  42398. * Disposes the component and the associated ressources.
  42399. */
  42400. dispose(): void;
  42401. }
  42402. }
  42403. declare module BABYLON {
  42404. /**
  42405. * Renders a layer on top of an existing scene
  42406. */
  42407. export class UtilityLayerRenderer implements IDisposable {
  42408. /** the original scene that will be rendered on top of */
  42409. originalScene: Scene;
  42410. private _pointerCaptures;
  42411. private _lastPointerEvents;
  42412. private static _DefaultUtilityLayer;
  42413. private static _DefaultKeepDepthUtilityLayer;
  42414. private _sharedGizmoLight;
  42415. private _renderCamera;
  42416. /**
  42417. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42418. * @returns the camera that is used when rendering the utility layer
  42419. */
  42420. getRenderCamera(): Nullable<Camera>;
  42421. /**
  42422. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42423. * @param cam the camera that should be used when rendering the utility layer
  42424. */
  42425. setRenderCamera(cam: Nullable<Camera>): void;
  42426. /**
  42427. * @hidden
  42428. * Light which used by gizmos to get light shading
  42429. */
  42430. _getSharedGizmoLight(): HemisphericLight;
  42431. /**
  42432. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42433. */
  42434. pickUtilitySceneFirst: boolean;
  42435. /**
  42436. * 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)
  42437. */
  42438. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42439. /**
  42440. * 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)
  42441. */
  42442. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42443. /**
  42444. * The scene that is rendered on top of the original scene
  42445. */
  42446. utilityLayerScene: Scene;
  42447. /**
  42448. * If the utility layer should automatically be rendered on top of existing scene
  42449. */
  42450. shouldRender: boolean;
  42451. /**
  42452. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42453. */
  42454. onlyCheckPointerDownEvents: boolean;
  42455. /**
  42456. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42457. */
  42458. processAllEvents: boolean;
  42459. /**
  42460. * Observable raised when the pointer move from the utility layer scene to the main scene
  42461. */
  42462. onPointerOutObservable: Observable<number>;
  42463. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42464. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42465. private _afterRenderObserver;
  42466. private _sceneDisposeObserver;
  42467. private _originalPointerObserver;
  42468. /**
  42469. * Instantiates a UtilityLayerRenderer
  42470. * @param originalScene the original scene that will be rendered on top of
  42471. * @param handleEvents boolean indicating if the utility layer should handle events
  42472. */
  42473. constructor(
  42474. /** the original scene that will be rendered on top of */
  42475. originalScene: Scene, handleEvents?: boolean);
  42476. private _notifyObservers;
  42477. /**
  42478. * Renders the utility layers scene on top of the original scene
  42479. */
  42480. render(): void;
  42481. /**
  42482. * Disposes of the renderer
  42483. */
  42484. dispose(): void;
  42485. private _updateCamera;
  42486. }
  42487. }
  42488. declare module BABYLON {
  42489. /**
  42490. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42491. */
  42492. export class Gizmo implements IDisposable {
  42493. /** The utility layer the gizmo will be added to */
  42494. gizmoLayer: UtilityLayerRenderer;
  42495. /**
  42496. * The root mesh of the gizmo
  42497. */
  42498. _rootMesh: Mesh;
  42499. private _attachedMesh;
  42500. /**
  42501. * Ratio for the scale of the gizmo (Default: 1)
  42502. */
  42503. scaleRatio: number;
  42504. /**
  42505. * If a custom mesh has been set (Default: false)
  42506. */
  42507. protected _customMeshSet: boolean;
  42508. /**
  42509. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42510. * * When set, interactions will be enabled
  42511. */
  42512. attachedMesh: Nullable<AbstractMesh>;
  42513. /**
  42514. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42515. * @param mesh The mesh to replace the default mesh of the gizmo
  42516. */
  42517. setCustomMesh(mesh: Mesh): void;
  42518. /**
  42519. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42520. */
  42521. updateGizmoRotationToMatchAttachedMesh: boolean;
  42522. /**
  42523. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42524. */
  42525. updateGizmoPositionToMatchAttachedMesh: boolean;
  42526. /**
  42527. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42528. */
  42529. updateScale: boolean;
  42530. protected _interactionsEnabled: boolean;
  42531. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42532. private _beforeRenderObserver;
  42533. private _tempVector;
  42534. /**
  42535. * Creates a gizmo
  42536. * @param gizmoLayer The utility layer the gizmo will be added to
  42537. */
  42538. constructor(
  42539. /** The utility layer the gizmo will be added to */
  42540. gizmoLayer?: UtilityLayerRenderer);
  42541. /**
  42542. * Updates the gizmo to match the attached mesh's position/rotation
  42543. */
  42544. protected _update(): void;
  42545. /**
  42546. * Disposes of the gizmo
  42547. */
  42548. dispose(): void;
  42549. }
  42550. }
  42551. declare module BABYLON {
  42552. /**
  42553. * Single plane drag gizmo
  42554. */
  42555. export class PlaneDragGizmo extends Gizmo {
  42556. /**
  42557. * Drag behavior responsible for the gizmos dragging interactions
  42558. */
  42559. dragBehavior: PointerDragBehavior;
  42560. private _pointerObserver;
  42561. /**
  42562. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42563. */
  42564. snapDistance: number;
  42565. /**
  42566. * Event that fires each time the gizmo snaps to a new location.
  42567. * * snapDistance is the the change in distance
  42568. */
  42569. onSnapObservable: Observable<{
  42570. snapDistance: number;
  42571. }>;
  42572. private _plane;
  42573. private _coloredMaterial;
  42574. private _hoverMaterial;
  42575. private _isEnabled;
  42576. private _parent;
  42577. /** @hidden */
  42578. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42579. /** @hidden */
  42580. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42581. /**
  42582. * Creates a PlaneDragGizmo
  42583. * @param gizmoLayer The utility layer the gizmo will be added to
  42584. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42585. * @param color The color of the gizmo
  42586. */
  42587. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42589. /**
  42590. * If the gizmo is enabled
  42591. */
  42592. isEnabled: boolean;
  42593. /**
  42594. * Disposes of the gizmo
  42595. */
  42596. dispose(): void;
  42597. }
  42598. }
  42599. declare module BABYLON {
  42600. /**
  42601. * Gizmo that enables dragging a mesh along 3 axis
  42602. */
  42603. export class PositionGizmo extends Gizmo {
  42604. /**
  42605. * Internal gizmo used for interactions on the x axis
  42606. */
  42607. xGizmo: AxisDragGizmo;
  42608. /**
  42609. * Internal gizmo used for interactions on the y axis
  42610. */
  42611. yGizmo: AxisDragGizmo;
  42612. /**
  42613. * Internal gizmo used for interactions on the z axis
  42614. */
  42615. zGizmo: AxisDragGizmo;
  42616. /**
  42617. * Internal gizmo used for interactions on the yz plane
  42618. */
  42619. xPlaneGizmo: PlaneDragGizmo;
  42620. /**
  42621. * Internal gizmo used for interactions on the xz plane
  42622. */
  42623. yPlaneGizmo: PlaneDragGizmo;
  42624. /**
  42625. * Internal gizmo used for interactions on the xy plane
  42626. */
  42627. zPlaneGizmo: PlaneDragGizmo;
  42628. /**
  42629. * private variables
  42630. */
  42631. private _meshAttached;
  42632. private _updateGizmoRotationToMatchAttachedMesh;
  42633. private _snapDistance;
  42634. private _scaleRatio;
  42635. /** Fires an event when any of it's sub gizmos are dragged */
  42636. onDragStartObservable: Observable<unknown>;
  42637. /** Fires an event when any of it's sub gizmos are released from dragging */
  42638. onDragEndObservable: Observable<unknown>;
  42639. /**
  42640. * If set to true, planar drag is enabled
  42641. */
  42642. private _planarGizmoEnabled;
  42643. attachedMesh: Nullable<AbstractMesh>;
  42644. /**
  42645. * Creates a PositionGizmo
  42646. * @param gizmoLayer The utility layer the gizmo will be added to
  42647. */
  42648. constructor(gizmoLayer?: UtilityLayerRenderer);
  42649. /**
  42650. * If the planar drag gizmo is enabled
  42651. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42652. */
  42653. planarGizmoEnabled: boolean;
  42654. updateGizmoRotationToMatchAttachedMesh: boolean;
  42655. /**
  42656. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42657. */
  42658. snapDistance: number;
  42659. /**
  42660. * Ratio for the scale of the gizmo (Default: 1)
  42661. */
  42662. scaleRatio: number;
  42663. /**
  42664. * Disposes of the gizmo
  42665. */
  42666. dispose(): void;
  42667. /**
  42668. * CustomMeshes are not supported by this gizmo
  42669. * @param mesh The mesh to replace the default mesh of the gizmo
  42670. */
  42671. setCustomMesh(mesh: Mesh): void;
  42672. }
  42673. }
  42674. declare module BABYLON {
  42675. /**
  42676. * Single axis drag gizmo
  42677. */
  42678. export class AxisDragGizmo extends Gizmo {
  42679. /**
  42680. * Drag behavior responsible for the gizmos dragging interactions
  42681. */
  42682. dragBehavior: PointerDragBehavior;
  42683. private _pointerObserver;
  42684. /**
  42685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42686. */
  42687. snapDistance: number;
  42688. /**
  42689. * Event that fires each time the gizmo snaps to a new location.
  42690. * * snapDistance is the the change in distance
  42691. */
  42692. onSnapObservable: Observable<{
  42693. snapDistance: number;
  42694. }>;
  42695. private _isEnabled;
  42696. private _parent;
  42697. private _arrow;
  42698. private _coloredMaterial;
  42699. private _hoverMaterial;
  42700. /** @hidden */
  42701. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42702. /** @hidden */
  42703. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42704. /**
  42705. * Creates an AxisDragGizmo
  42706. * @param gizmoLayer The utility layer the gizmo will be added to
  42707. * @param dragAxis The axis which the gizmo will be able to drag on
  42708. * @param color The color of the gizmo
  42709. */
  42710. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42711. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42712. /**
  42713. * If the gizmo is enabled
  42714. */
  42715. isEnabled: boolean;
  42716. /**
  42717. * Disposes of the gizmo
  42718. */
  42719. dispose(): void;
  42720. }
  42721. }
  42722. declare module BABYLON.Debug {
  42723. /**
  42724. * The Axes viewer will show 3 axes in a specific point in space
  42725. */
  42726. export class AxesViewer {
  42727. private _xAxis;
  42728. private _yAxis;
  42729. private _zAxis;
  42730. private _scaleLinesFactor;
  42731. private _instanced;
  42732. /**
  42733. * Gets the hosting scene
  42734. */
  42735. scene: Scene;
  42736. /**
  42737. * Gets or sets a number used to scale line length
  42738. */
  42739. scaleLines: number;
  42740. /** Gets the node hierarchy used to render x-axis */
  42741. readonly xAxis: TransformNode;
  42742. /** Gets the node hierarchy used to render y-axis */
  42743. readonly yAxis: TransformNode;
  42744. /** Gets the node hierarchy used to render z-axis */
  42745. readonly zAxis: TransformNode;
  42746. /**
  42747. * Creates a new AxesViewer
  42748. * @param scene defines the hosting scene
  42749. * @param scaleLines defines a number used to scale line length (1 by default)
  42750. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42751. * @param xAxis defines the node hierarchy used to render the x-axis
  42752. * @param yAxis defines the node hierarchy used to render the y-axis
  42753. * @param zAxis defines the node hierarchy used to render the z-axis
  42754. */
  42755. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42756. /**
  42757. * Force the viewer to update
  42758. * @param position defines the position of the viewer
  42759. * @param xaxis defines the x axis of the viewer
  42760. * @param yaxis defines the y axis of the viewer
  42761. * @param zaxis defines the z axis of the viewer
  42762. */
  42763. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42764. /**
  42765. * Creates an instance of this axes viewer.
  42766. * @returns a new axes viewer with instanced meshes
  42767. */
  42768. createInstance(): AxesViewer;
  42769. /** Releases resources */
  42770. dispose(): void;
  42771. private static _SetRenderingGroupId;
  42772. }
  42773. }
  42774. declare module BABYLON.Debug {
  42775. /**
  42776. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42777. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42778. */
  42779. export class BoneAxesViewer extends AxesViewer {
  42780. /**
  42781. * Gets or sets the target mesh where to display the axes viewer
  42782. */
  42783. mesh: Nullable<Mesh>;
  42784. /**
  42785. * Gets or sets the target bone where to display the axes viewer
  42786. */
  42787. bone: Nullable<Bone>;
  42788. /** Gets current position */
  42789. pos: Vector3;
  42790. /** Gets direction of X axis */
  42791. xaxis: Vector3;
  42792. /** Gets direction of Y axis */
  42793. yaxis: Vector3;
  42794. /** Gets direction of Z axis */
  42795. zaxis: Vector3;
  42796. /**
  42797. * Creates a new BoneAxesViewer
  42798. * @param scene defines the hosting scene
  42799. * @param bone defines the target bone
  42800. * @param mesh defines the target mesh
  42801. * @param scaleLines defines a scaling factor for line length (1 by default)
  42802. */
  42803. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42804. /**
  42805. * Force the viewer to update
  42806. */
  42807. update(): void;
  42808. /** Releases resources */
  42809. dispose(): void;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. /**
  42814. * Interface used to define scene explorer extensibility option
  42815. */
  42816. export interface IExplorerExtensibilityOption {
  42817. /**
  42818. * Define the option label
  42819. */
  42820. label: string;
  42821. /**
  42822. * Defines the action to execute on click
  42823. */
  42824. action: (entity: any) => void;
  42825. }
  42826. /**
  42827. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42828. */
  42829. export interface IExplorerExtensibilityGroup {
  42830. /**
  42831. * Defines a predicate to test if a given type mut be extended
  42832. */
  42833. predicate: (entity: any) => boolean;
  42834. /**
  42835. * Gets the list of options added to a type
  42836. */
  42837. entries: IExplorerExtensibilityOption[];
  42838. }
  42839. /**
  42840. * Interface used to define the options to use to create the Inspector
  42841. */
  42842. export interface IInspectorOptions {
  42843. /**
  42844. * Display in overlay mode (default: false)
  42845. */
  42846. overlay?: boolean;
  42847. /**
  42848. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42849. */
  42850. globalRoot?: HTMLElement;
  42851. /**
  42852. * Display the Scene explorer
  42853. */
  42854. showExplorer?: boolean;
  42855. /**
  42856. * Display the property inspector
  42857. */
  42858. showInspector?: boolean;
  42859. /**
  42860. * Display in embed mode (both panes on the right)
  42861. */
  42862. embedMode?: boolean;
  42863. /**
  42864. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42865. */
  42866. handleResize?: boolean;
  42867. /**
  42868. * Allow the panes to popup (default: true)
  42869. */
  42870. enablePopup?: boolean;
  42871. /**
  42872. * Allow the panes to be closed by users (default: true)
  42873. */
  42874. enableClose?: boolean;
  42875. /**
  42876. * Optional list of extensibility entries
  42877. */
  42878. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42879. /**
  42880. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42881. */
  42882. inspectorURL?: string;
  42883. }
  42884. interface Scene {
  42885. /**
  42886. * @hidden
  42887. * Backing field
  42888. */
  42889. _debugLayer: DebugLayer;
  42890. /**
  42891. * Gets the debug layer (aka Inspector) associated with the scene
  42892. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42893. */
  42894. debugLayer: DebugLayer;
  42895. }
  42896. /**
  42897. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42898. * what is happening in your scene
  42899. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42900. */
  42901. export class DebugLayer {
  42902. /**
  42903. * Define the url to get the inspector script from.
  42904. * By default it uses the babylonjs CDN.
  42905. * @ignoreNaming
  42906. */
  42907. static InspectorURL: string;
  42908. private _scene;
  42909. private BJSINSPECTOR;
  42910. private _onPropertyChangedObservable?;
  42911. /**
  42912. * Observable triggered when a property is changed through the inspector.
  42913. */
  42914. readonly onPropertyChangedObservable: any;
  42915. /**
  42916. * Instantiates a new debug layer.
  42917. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42918. * what is happening in your scene
  42919. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42920. * @param scene Defines the scene to inspect
  42921. */
  42922. constructor(scene: Scene);
  42923. /** Creates the inspector window. */
  42924. private _createInspector;
  42925. /**
  42926. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42927. * @param entity defines the entity to select
  42928. * @param lineContainerTitle defines the specific block to highlight
  42929. */
  42930. select(entity: any, lineContainerTitle?: string): void;
  42931. /** Get the inspector from bundle or global */
  42932. private _getGlobalInspector;
  42933. /**
  42934. * Get if the inspector is visible or not.
  42935. * @returns true if visible otherwise, false
  42936. */
  42937. isVisible(): boolean;
  42938. /**
  42939. * Hide the inspector and close its window.
  42940. */
  42941. hide(): void;
  42942. /**
  42943. * Launch the debugLayer.
  42944. * @param config Define the configuration of the inspector
  42945. * @return a promise fulfilled when the debug layer is visible
  42946. */
  42947. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42948. }
  42949. }
  42950. declare module BABYLON {
  42951. /**
  42952. * Class containing static functions to help procedurally build meshes
  42953. */
  42954. export class BoxBuilder {
  42955. /**
  42956. * Creates a box mesh
  42957. * * The parameter `size` sets the size (float) of each box side (default 1)
  42958. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42959. * * 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)
  42960. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42962. * * 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
  42963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42964. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42965. * @param name defines the name of the mesh
  42966. * @param options defines the options used to create the mesh
  42967. * @param scene defines the hosting scene
  42968. * @returns the box mesh
  42969. */
  42970. static CreateBox(name: string, options: {
  42971. size?: number;
  42972. width?: number;
  42973. height?: number;
  42974. depth?: number;
  42975. faceUV?: Vector4[];
  42976. faceColors?: Color4[];
  42977. sideOrientation?: number;
  42978. frontUVs?: Vector4;
  42979. backUVs?: Vector4;
  42980. wrap?: boolean;
  42981. topBaseAt?: number;
  42982. bottomBaseAt?: number;
  42983. updatable?: boolean;
  42984. }, scene?: Nullable<Scene>): Mesh;
  42985. }
  42986. }
  42987. declare module BABYLON {
  42988. /**
  42989. * Class containing static functions to help procedurally build meshes
  42990. */
  42991. export class SphereBuilder {
  42992. /**
  42993. * Creates a sphere mesh
  42994. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42995. * * 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`)
  42996. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42997. * * 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
  42998. * * 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)
  42999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43000. * * 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
  43001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43002. * @param name defines the name of the mesh
  43003. * @param options defines the options used to create the mesh
  43004. * @param scene defines the hosting scene
  43005. * @returns the sphere mesh
  43006. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43007. */
  43008. static CreateSphere(name: string, options: {
  43009. segments?: number;
  43010. diameter?: number;
  43011. diameterX?: number;
  43012. diameterY?: number;
  43013. diameterZ?: number;
  43014. arc?: number;
  43015. slice?: number;
  43016. sideOrientation?: number;
  43017. frontUVs?: Vector4;
  43018. backUVs?: Vector4;
  43019. updatable?: boolean;
  43020. }, scene: any): Mesh;
  43021. }
  43022. }
  43023. declare module BABYLON.Debug {
  43024. /**
  43025. * Used to show the physics impostor around the specific mesh
  43026. */
  43027. export class PhysicsViewer {
  43028. /** @hidden */
  43029. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43030. /** @hidden */
  43031. protected _meshes: Array<Nullable<AbstractMesh>>;
  43032. /** @hidden */
  43033. protected _scene: Nullable<Scene>;
  43034. /** @hidden */
  43035. protected _numMeshes: number;
  43036. /** @hidden */
  43037. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43038. private _renderFunction;
  43039. private _utilityLayer;
  43040. private _debugBoxMesh;
  43041. private _debugSphereMesh;
  43042. private _debugCylinderMesh;
  43043. private _debugMaterial;
  43044. private _debugMeshMeshes;
  43045. /**
  43046. * Creates a new PhysicsViewer
  43047. * @param scene defines the hosting scene
  43048. */
  43049. constructor(scene: Scene);
  43050. /** @hidden */
  43051. protected _updateDebugMeshes(): void;
  43052. /**
  43053. * Renders a specified physic impostor
  43054. * @param impostor defines the impostor to render
  43055. * @param targetMesh defines the mesh represented by the impostor
  43056. * @returns the new debug mesh used to render the impostor
  43057. */
  43058. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43059. /**
  43060. * Hides a specified physic impostor
  43061. * @param impostor defines the impostor to hide
  43062. */
  43063. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43064. private _getDebugMaterial;
  43065. private _getDebugBoxMesh;
  43066. private _getDebugSphereMesh;
  43067. private _getDebugCylinderMesh;
  43068. private _getDebugMeshMesh;
  43069. private _getDebugMesh;
  43070. /** Releases all resources */
  43071. dispose(): void;
  43072. }
  43073. }
  43074. declare module BABYLON {
  43075. /**
  43076. * Class containing static functions to help procedurally build meshes
  43077. */
  43078. export class LinesBuilder {
  43079. /**
  43080. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43081. * * 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
  43082. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43083. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43084. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43085. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43086. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43087. * * 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
  43088. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43091. * @param name defines the name of the new line system
  43092. * @param options defines the options used to create the line system
  43093. * @param scene defines the hosting scene
  43094. * @returns a new line system mesh
  43095. */
  43096. static CreateLineSystem(name: string, options: {
  43097. lines: Vector3[][];
  43098. updatable?: boolean;
  43099. instance?: Nullable<LinesMesh>;
  43100. colors?: Nullable<Color4[][]>;
  43101. useVertexAlpha?: boolean;
  43102. }, scene: Nullable<Scene>): LinesMesh;
  43103. /**
  43104. * Creates a line mesh
  43105. * 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
  43106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43107. * * The parameter `points` is an array successive Vector3
  43108. * * 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
  43109. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43110. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43111. * * When updating an instance, remember that only point positions can change, not the number of points
  43112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43114. * @param name defines the name of the new line system
  43115. * @param options defines the options used to create the line system
  43116. * @param scene defines the hosting scene
  43117. * @returns a new line mesh
  43118. */
  43119. static CreateLines(name: string, options: {
  43120. points: Vector3[];
  43121. updatable?: boolean;
  43122. instance?: Nullable<LinesMesh>;
  43123. colors?: Color4[];
  43124. useVertexAlpha?: boolean;
  43125. }, scene?: Nullable<Scene>): LinesMesh;
  43126. /**
  43127. * Creates a dashed line mesh
  43128. * * 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
  43129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43130. * * The parameter `points` is an array successive Vector3
  43131. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43132. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43133. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43134. * * 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
  43135. * * When updating an instance, remember that only point positions can change, not the number of points
  43136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43137. * @param name defines the name of the mesh
  43138. * @param options defines the options used to create the mesh
  43139. * @param scene defines the hosting scene
  43140. * @returns the dashed line mesh
  43141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43142. */
  43143. static CreateDashedLines(name: string, options: {
  43144. points: Vector3[];
  43145. dashSize?: number;
  43146. gapSize?: number;
  43147. dashNb?: number;
  43148. updatable?: boolean;
  43149. instance?: LinesMesh;
  43150. }, scene?: Nullable<Scene>): LinesMesh;
  43151. }
  43152. }
  43153. declare module BABYLON {
  43154. /**
  43155. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43156. * in order to better appreciate the issue one might have.
  43157. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43158. */
  43159. export class RayHelper {
  43160. /**
  43161. * Defines the ray we are currently tryin to visualize.
  43162. */
  43163. ray: Nullable<Ray>;
  43164. private _renderPoints;
  43165. private _renderLine;
  43166. private _renderFunction;
  43167. private _scene;
  43168. private _updateToMeshFunction;
  43169. private _attachedToMesh;
  43170. private _meshSpaceDirection;
  43171. private _meshSpaceOrigin;
  43172. /**
  43173. * Helper function to create a colored helper in a scene in one line.
  43174. * @param ray Defines the ray we are currently tryin to visualize
  43175. * @param scene Defines the scene the ray is used in
  43176. * @param color Defines the color we want to see the ray in
  43177. * @returns The newly created ray helper.
  43178. */
  43179. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43180. /**
  43181. * Instantiate a new ray helper.
  43182. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43183. * in order to better appreciate the issue one might have.
  43184. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43185. * @param ray Defines the ray we are currently tryin to visualize
  43186. */
  43187. constructor(ray: Ray);
  43188. /**
  43189. * Shows the ray we are willing to debug.
  43190. * @param scene Defines the scene the ray needs to be rendered in
  43191. * @param color Defines the color the ray needs to be rendered in
  43192. */
  43193. show(scene: Scene, color?: Color3): void;
  43194. /**
  43195. * Hides the ray we are debugging.
  43196. */
  43197. hide(): void;
  43198. private _render;
  43199. /**
  43200. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43201. * @param mesh Defines the mesh we want the helper attached to
  43202. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43203. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43204. * @param length Defines the length of the ray
  43205. */
  43206. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43207. /**
  43208. * Detach the ray helper from the mesh it has previously been attached to.
  43209. */
  43210. detachFromMesh(): void;
  43211. private _updateToMesh;
  43212. /**
  43213. * Dispose the helper and release its associated resources.
  43214. */
  43215. dispose(): void;
  43216. }
  43217. }
  43218. declare module BABYLON.Debug {
  43219. /**
  43220. * Class used to render a debug view of a given skeleton
  43221. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43222. */
  43223. export class SkeletonViewer {
  43224. /** defines the skeleton to render */
  43225. skeleton: Skeleton;
  43226. /** defines the mesh attached to the skeleton */
  43227. mesh: AbstractMesh;
  43228. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43229. autoUpdateBonesMatrices: boolean;
  43230. /** defines the rendering group id to use with the viewer */
  43231. renderingGroupId: number;
  43232. /** Gets or sets the color used to render the skeleton */
  43233. color: Color3;
  43234. private _scene;
  43235. private _debugLines;
  43236. private _debugMesh;
  43237. private _isEnabled;
  43238. private _renderFunction;
  43239. private _utilityLayer;
  43240. /**
  43241. * Returns the mesh used to render the bones
  43242. */
  43243. readonly debugMesh: Nullable<LinesMesh>;
  43244. /**
  43245. * Creates a new SkeletonViewer
  43246. * @param skeleton defines the skeleton to render
  43247. * @param mesh defines the mesh attached to the skeleton
  43248. * @param scene defines the hosting scene
  43249. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43250. * @param renderingGroupId defines the rendering group id to use with the viewer
  43251. */
  43252. constructor(
  43253. /** defines the skeleton to render */
  43254. skeleton: Skeleton,
  43255. /** defines the mesh attached to the skeleton */
  43256. mesh: AbstractMesh, scene: Scene,
  43257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43258. autoUpdateBonesMatrices?: boolean,
  43259. /** defines the rendering group id to use with the viewer */
  43260. renderingGroupId?: number);
  43261. /** Gets or sets a boolean indicating if the viewer is enabled */
  43262. isEnabled: boolean;
  43263. private _getBonePosition;
  43264. private _getLinesForBonesWithLength;
  43265. private _getLinesForBonesNoLength;
  43266. /** Update the viewer to sync with current skeleton state */
  43267. update(): void;
  43268. /** Release associated resources */
  43269. dispose(): void;
  43270. }
  43271. }
  43272. declare module BABYLON {
  43273. /**
  43274. * Options to create the null engine
  43275. */
  43276. export class NullEngineOptions {
  43277. /**
  43278. * Render width (Default: 512)
  43279. */
  43280. renderWidth: number;
  43281. /**
  43282. * Render height (Default: 256)
  43283. */
  43284. renderHeight: number;
  43285. /**
  43286. * Texture size (Default: 512)
  43287. */
  43288. textureSize: number;
  43289. /**
  43290. * If delta time between frames should be constant
  43291. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43292. */
  43293. deterministicLockstep: boolean;
  43294. /**
  43295. * Maximum about of steps between frames (Default: 4)
  43296. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43297. */
  43298. lockstepMaxSteps: number;
  43299. }
  43300. /**
  43301. * The null engine class provides support for headless version of babylon.js.
  43302. * This can be used in server side scenario or for testing purposes
  43303. */
  43304. export class NullEngine extends Engine {
  43305. private _options;
  43306. /**
  43307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43308. */
  43309. isDeterministicLockStep(): boolean;
  43310. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43311. getLockstepMaxSteps(): number;
  43312. /**
  43313. * Sets hardware scaling, used to save performance if needed
  43314. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43315. */
  43316. getHardwareScalingLevel(): number;
  43317. constructor(options?: NullEngineOptions);
  43318. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43319. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43320. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43321. getRenderWidth(useScreen?: boolean): number;
  43322. getRenderHeight(useScreen?: boolean): number;
  43323. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43324. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43325. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43326. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43327. bindSamplers(effect: Effect): void;
  43328. enableEffect(effect: Effect): void;
  43329. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43330. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43331. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43332. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43333. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43334. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43335. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43336. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43337. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43338. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43339. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43340. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43341. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43342. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43343. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43344. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43345. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43346. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43347. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43348. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43349. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43350. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43351. bindBuffers(vertexBuffers: {
  43352. [key: string]: VertexBuffer;
  43353. }, indexBuffer: DataBuffer, effect: Effect): void;
  43354. wipeCaches(bruteForce?: boolean): void;
  43355. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43356. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43357. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43358. /** @hidden */
  43359. _createTexture(): WebGLTexture;
  43360. /** @hidden */
  43361. _releaseTexture(texture: InternalTexture): void;
  43362. 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;
  43363. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43364. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43365. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43366. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43367. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43368. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43369. areAllEffectsReady(): boolean;
  43370. /**
  43371. * @hidden
  43372. * Get the current error code of the webGL context
  43373. * @returns the error code
  43374. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43375. */
  43376. getError(): number;
  43377. /** @hidden */
  43378. _getUnpackAlignement(): number;
  43379. /** @hidden */
  43380. _unpackFlipY(value: boolean): void;
  43381. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43382. /**
  43383. * Updates a dynamic vertex buffer.
  43384. * @param vertexBuffer the vertex buffer to update
  43385. * @param data the data used to update the vertex buffer
  43386. * @param byteOffset the byte offset of the data (optional)
  43387. * @param byteLength the byte length of the data (optional)
  43388. */
  43389. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43390. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43391. /** @hidden */
  43392. _bindTexture(channel: number, texture: InternalTexture): void;
  43393. /** @hidden */
  43394. _releaseBuffer(buffer: DataBuffer): boolean;
  43395. releaseEffects(): void;
  43396. displayLoadingUI(): void;
  43397. hideLoadingUI(): void;
  43398. /** @hidden */
  43399. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43400. /** @hidden */
  43401. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43402. /** @hidden */
  43403. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43404. /** @hidden */
  43405. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43406. }
  43407. }
  43408. declare module BABYLON {
  43409. /** @hidden */
  43410. export class _OcclusionDataStorage {
  43411. /** @hidden */
  43412. occlusionInternalRetryCounter: number;
  43413. /** @hidden */
  43414. isOcclusionQueryInProgress: boolean;
  43415. /** @hidden */
  43416. isOccluded: boolean;
  43417. /** @hidden */
  43418. occlusionRetryCount: number;
  43419. /** @hidden */
  43420. occlusionType: number;
  43421. /** @hidden */
  43422. occlusionQueryAlgorithmType: number;
  43423. }
  43424. interface Engine {
  43425. /**
  43426. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43427. * @return the new query
  43428. */
  43429. createQuery(): WebGLQuery;
  43430. /**
  43431. * Delete and release a webGL query
  43432. * @param query defines the query to delete
  43433. * @return the current engine
  43434. */
  43435. deleteQuery(query: WebGLQuery): Engine;
  43436. /**
  43437. * Check if a given query has resolved and got its value
  43438. * @param query defines the query to check
  43439. * @returns true if the query got its value
  43440. */
  43441. isQueryResultAvailable(query: WebGLQuery): boolean;
  43442. /**
  43443. * Gets the value of a given query
  43444. * @param query defines the query to check
  43445. * @returns the value of the query
  43446. */
  43447. getQueryResult(query: WebGLQuery): number;
  43448. /**
  43449. * Initiates an occlusion query
  43450. * @param algorithmType defines the algorithm to use
  43451. * @param query defines the query to use
  43452. * @returns the current engine
  43453. * @see http://doc.babylonjs.com/features/occlusionquery
  43454. */
  43455. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43456. /**
  43457. * Ends an occlusion query
  43458. * @see http://doc.babylonjs.com/features/occlusionquery
  43459. * @param algorithmType defines the algorithm to use
  43460. * @returns the current engine
  43461. */
  43462. endOcclusionQuery(algorithmType: number): Engine;
  43463. /**
  43464. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43465. * Please note that only one query can be issued at a time
  43466. * @returns a time token used to track the time span
  43467. */
  43468. startTimeQuery(): Nullable<_TimeToken>;
  43469. /**
  43470. * Ends a time query
  43471. * @param token defines the token used to measure the time span
  43472. * @returns the time spent (in ns)
  43473. */
  43474. endTimeQuery(token: _TimeToken): int;
  43475. /** @hidden */
  43476. _currentNonTimestampToken: Nullable<_TimeToken>;
  43477. /** @hidden */
  43478. _createTimeQuery(): WebGLQuery;
  43479. /** @hidden */
  43480. _deleteTimeQuery(query: WebGLQuery): void;
  43481. /** @hidden */
  43482. _getGlAlgorithmType(algorithmType: number): number;
  43483. /** @hidden */
  43484. _getTimeQueryResult(query: WebGLQuery): any;
  43485. /** @hidden */
  43486. _getTimeQueryAvailability(query: WebGLQuery): any;
  43487. }
  43488. interface AbstractMesh {
  43489. /**
  43490. * Backing filed
  43491. * @hidden
  43492. */
  43493. __occlusionDataStorage: _OcclusionDataStorage;
  43494. /**
  43495. * Access property
  43496. * @hidden
  43497. */
  43498. _occlusionDataStorage: _OcclusionDataStorage;
  43499. /**
  43500. * 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.
  43501. * The default value is -1 which means don't break the query and wait till the result
  43502. * @see http://doc.babylonjs.com/features/occlusionquery
  43503. */
  43504. occlusionRetryCount: number;
  43505. /**
  43506. * 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:
  43507. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43508. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43509. * * 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.
  43510. * @see http://doc.babylonjs.com/features/occlusionquery
  43511. */
  43512. occlusionType: number;
  43513. /**
  43514. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43515. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43516. * * 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.
  43517. * @see http://doc.babylonjs.com/features/occlusionquery
  43518. */
  43519. occlusionQueryAlgorithmType: number;
  43520. /**
  43521. * 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
  43522. * @see http://doc.babylonjs.com/features/occlusionquery
  43523. */
  43524. isOccluded: boolean;
  43525. /**
  43526. * Flag to check the progress status of the query
  43527. * @see http://doc.babylonjs.com/features/occlusionquery
  43528. */
  43529. isOcclusionQueryInProgress: boolean;
  43530. }
  43531. }
  43532. declare module BABYLON {
  43533. /** @hidden */
  43534. export var _forceTransformFeedbackToBundle: boolean;
  43535. interface Engine {
  43536. /**
  43537. * Creates a webGL transform feedback object
  43538. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43539. * @returns the webGL transform feedback object
  43540. */
  43541. createTransformFeedback(): WebGLTransformFeedback;
  43542. /**
  43543. * Delete a webGL transform feedback object
  43544. * @param value defines the webGL transform feedback object to delete
  43545. */
  43546. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43547. /**
  43548. * Bind a webGL transform feedback object to the webgl context
  43549. * @param value defines the webGL transform feedback object to bind
  43550. */
  43551. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43552. /**
  43553. * Begins a transform feedback operation
  43554. * @param usePoints defines if points or triangles must be used
  43555. */
  43556. beginTransformFeedback(usePoints: boolean): void;
  43557. /**
  43558. * Ends a transform feedback operation
  43559. */
  43560. endTransformFeedback(): void;
  43561. /**
  43562. * Specify the varyings to use with transform feedback
  43563. * @param program defines the associated webGL program
  43564. * @param value defines the list of strings representing the varying names
  43565. */
  43566. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43567. /**
  43568. * Bind a webGL buffer for a transform feedback operation
  43569. * @param value defines the webGL buffer to bind
  43570. */
  43571. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43572. }
  43573. }
  43574. declare module BABYLON {
  43575. /**
  43576. * Creation options of the multi render target texture.
  43577. */
  43578. export interface IMultiRenderTargetOptions {
  43579. /**
  43580. * Define if the texture needs to create mip maps after render.
  43581. */
  43582. generateMipMaps?: boolean;
  43583. /**
  43584. * Define the types of all the draw buffers we want to create
  43585. */
  43586. types?: number[];
  43587. /**
  43588. * Define the sampling modes of all the draw buffers we want to create
  43589. */
  43590. samplingModes?: number[];
  43591. /**
  43592. * Define if a depth buffer is required
  43593. */
  43594. generateDepthBuffer?: boolean;
  43595. /**
  43596. * Define if a stencil buffer is required
  43597. */
  43598. generateStencilBuffer?: boolean;
  43599. /**
  43600. * Define if a depth texture is required instead of a depth buffer
  43601. */
  43602. generateDepthTexture?: boolean;
  43603. /**
  43604. * Define the number of desired draw buffers
  43605. */
  43606. textureCount?: number;
  43607. /**
  43608. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43609. */
  43610. doNotChangeAspectRatio?: boolean;
  43611. /**
  43612. * Define the default type of the buffers we are creating
  43613. */
  43614. defaultType?: number;
  43615. }
  43616. /**
  43617. * A multi render target, like a render target provides the ability to render to a texture.
  43618. * Unlike the render target, it can render to several draw buffers in one draw.
  43619. * This is specially interesting in deferred rendering or for any effects requiring more than
  43620. * just one color from a single pass.
  43621. */
  43622. export class MultiRenderTarget extends RenderTargetTexture {
  43623. private _internalTextures;
  43624. private _textures;
  43625. private _multiRenderTargetOptions;
  43626. /**
  43627. * Get if draw buffers are currently supported by the used hardware and browser.
  43628. */
  43629. readonly isSupported: boolean;
  43630. /**
  43631. * Get the list of textures generated by the multi render target.
  43632. */
  43633. readonly textures: Texture[];
  43634. /**
  43635. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43636. */
  43637. readonly depthTexture: Texture;
  43638. /**
  43639. * Set the wrapping mode on U of all the textures we are rendering to.
  43640. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43641. */
  43642. wrapU: number;
  43643. /**
  43644. * Set the wrapping mode on V of all the textures we are rendering to.
  43645. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43646. */
  43647. wrapV: number;
  43648. /**
  43649. * Instantiate a new multi render target texture.
  43650. * A multi render target, like a render target provides the ability to render to a texture.
  43651. * Unlike the render target, it can render to several draw buffers in one draw.
  43652. * This is specially interesting in deferred rendering or for any effects requiring more than
  43653. * just one color from a single pass.
  43654. * @param name Define the name of the texture
  43655. * @param size Define the size of the buffers to render to
  43656. * @param count Define the number of target we are rendering into
  43657. * @param scene Define the scene the texture belongs to
  43658. * @param options Define the options used to create the multi render target
  43659. */
  43660. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43661. /** @hidden */
  43662. _rebuild(): void;
  43663. private _createInternalTextures;
  43664. private _createTextures;
  43665. /**
  43666. * Define the number of samples used if MSAA is enabled.
  43667. */
  43668. samples: number;
  43669. /**
  43670. * Resize all the textures in the multi render target.
  43671. * Be carrefull as it will recreate all the data in the new texture.
  43672. * @param size Define the new size
  43673. */
  43674. resize(size: any): void;
  43675. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43676. /**
  43677. * Dispose the render targets and their associated resources
  43678. */
  43679. dispose(): void;
  43680. /**
  43681. * Release all the underlying texture used as draw buffers.
  43682. */
  43683. releaseInternalTextures(): void;
  43684. }
  43685. }
  43686. declare module BABYLON {
  43687. interface Engine {
  43688. /**
  43689. * Unbind a list of render target textures from the webGL context
  43690. * This is used only when drawBuffer extension or webGL2 are active
  43691. * @param textures defines the render target textures to unbind
  43692. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43693. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43694. */
  43695. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43696. /**
  43697. * Create a multi render target texture
  43698. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43699. * @param size defines the size of the texture
  43700. * @param options defines the creation options
  43701. * @returns the cube texture as an InternalTexture
  43702. */
  43703. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43704. /**
  43705. * Update the sample count for a given multiple render target texture
  43706. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43707. * @param textures defines the textures to update
  43708. * @param samples defines the sample count to set
  43709. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43710. */
  43711. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43712. }
  43713. }
  43714. declare module BABYLON {
  43715. /**
  43716. * Gather the list of clipboard event types as constants.
  43717. */
  43718. export class ClipboardEventTypes {
  43719. /**
  43720. * The clipboard event is fired when a copy command is active (pressed).
  43721. */
  43722. static readonly COPY: number;
  43723. /**
  43724. * The clipboard event is fired when a cut command is active (pressed).
  43725. */
  43726. static readonly CUT: number;
  43727. /**
  43728. * The clipboard event is fired when a paste command is active (pressed).
  43729. */
  43730. static readonly PASTE: number;
  43731. }
  43732. /**
  43733. * This class is used to store clipboard related info for the onClipboardObservable event.
  43734. */
  43735. export class ClipboardInfo {
  43736. /**
  43737. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43738. */
  43739. type: number;
  43740. /**
  43741. * Defines the related dom event
  43742. */
  43743. event: ClipboardEvent;
  43744. /**
  43745. *Creates an instance of ClipboardInfo.
  43746. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43747. * @param event Defines the related dom event
  43748. */
  43749. constructor(
  43750. /**
  43751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43752. */
  43753. type: number,
  43754. /**
  43755. * Defines the related dom event
  43756. */
  43757. event: ClipboardEvent);
  43758. /**
  43759. * Get the clipboard event's type from the keycode.
  43760. * @param keyCode Defines the keyCode for the current keyboard event.
  43761. * @return {number}
  43762. */
  43763. static GetTypeFromCharacter(keyCode: number): number;
  43764. }
  43765. }
  43766. declare module BABYLON {
  43767. /**
  43768. * Google Daydream controller
  43769. */
  43770. export class DaydreamController extends WebVRController {
  43771. /**
  43772. * Base Url for the controller model.
  43773. */
  43774. static MODEL_BASE_URL: string;
  43775. /**
  43776. * File name for the controller model.
  43777. */
  43778. static MODEL_FILENAME: string;
  43779. /**
  43780. * Gamepad Id prefix used to identify Daydream Controller.
  43781. */
  43782. static readonly GAMEPAD_ID_PREFIX: string;
  43783. /**
  43784. * Creates a new DaydreamController from a gamepad
  43785. * @param vrGamepad the gamepad that the controller should be created from
  43786. */
  43787. constructor(vrGamepad: any);
  43788. /**
  43789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43790. * @param scene scene in which to add meshes
  43791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43792. */
  43793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43794. /**
  43795. * Called once for each button that changed state since the last frame
  43796. * @param buttonIdx Which button index changed
  43797. * @param state New state of the button
  43798. * @param changes Which properties on the state changed since last frame
  43799. */
  43800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43801. }
  43802. }
  43803. declare module BABYLON {
  43804. /**
  43805. * Gear VR Controller
  43806. */
  43807. export class GearVRController extends WebVRController {
  43808. /**
  43809. * Base Url for the controller model.
  43810. */
  43811. static MODEL_BASE_URL: string;
  43812. /**
  43813. * File name for the controller model.
  43814. */
  43815. static MODEL_FILENAME: string;
  43816. /**
  43817. * Gamepad Id prefix used to identify this controller.
  43818. */
  43819. static readonly GAMEPAD_ID_PREFIX: string;
  43820. private readonly _buttonIndexToObservableNameMap;
  43821. /**
  43822. * Creates a new GearVRController from a gamepad
  43823. * @param vrGamepad the gamepad that the controller should be created from
  43824. */
  43825. constructor(vrGamepad: any);
  43826. /**
  43827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43828. * @param scene scene in which to add meshes
  43829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43830. */
  43831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43832. /**
  43833. * Called once for each button that changed state since the last frame
  43834. * @param buttonIdx Which button index changed
  43835. * @param state New state of the button
  43836. * @param changes Which properties on the state changed since last frame
  43837. */
  43838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43839. }
  43840. }
  43841. declare module BABYLON {
  43842. /**
  43843. * Class containing static functions to help procedurally build meshes
  43844. */
  43845. export class PolyhedronBuilder {
  43846. /**
  43847. * Creates a polyhedron mesh
  43848. * * 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
  43849. * * The parameter `size` (positive float, default 1) sets the polygon size
  43850. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43851. * * 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`
  43852. * * 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
  43853. * * 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)`)
  43854. * * 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
  43855. * * 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
  43856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43857. * * 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
  43858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43859. * @param name defines the name of the mesh
  43860. * @param options defines the options used to create the mesh
  43861. * @param scene defines the hosting scene
  43862. * @returns the polyhedron mesh
  43863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43864. */
  43865. static CreatePolyhedron(name: string, options: {
  43866. type?: number;
  43867. size?: number;
  43868. sizeX?: number;
  43869. sizeY?: number;
  43870. sizeZ?: number;
  43871. custom?: any;
  43872. faceUV?: Vector4[];
  43873. faceColors?: Color4[];
  43874. flat?: boolean;
  43875. updatable?: boolean;
  43876. sideOrientation?: number;
  43877. frontUVs?: Vector4;
  43878. backUVs?: Vector4;
  43879. }, scene?: Nullable<Scene>): Mesh;
  43880. }
  43881. }
  43882. declare module BABYLON {
  43883. /**
  43884. * Gizmo that enables scaling a mesh along 3 axis
  43885. */
  43886. export class ScaleGizmo extends Gizmo {
  43887. /**
  43888. * Internal gizmo used for interactions on the x axis
  43889. */
  43890. xGizmo: AxisScaleGizmo;
  43891. /**
  43892. * Internal gizmo used for interactions on the y axis
  43893. */
  43894. yGizmo: AxisScaleGizmo;
  43895. /**
  43896. * Internal gizmo used for interactions on the z axis
  43897. */
  43898. zGizmo: AxisScaleGizmo;
  43899. /**
  43900. * Internal gizmo used to scale all axis equally
  43901. */
  43902. uniformScaleGizmo: AxisScaleGizmo;
  43903. private _meshAttached;
  43904. private _updateGizmoRotationToMatchAttachedMesh;
  43905. private _snapDistance;
  43906. private _scaleRatio;
  43907. private _uniformScalingMesh;
  43908. private _octahedron;
  43909. /** Fires an event when any of it's sub gizmos are dragged */
  43910. onDragStartObservable: Observable<unknown>;
  43911. /** Fires an event when any of it's sub gizmos are released from dragging */
  43912. onDragEndObservable: Observable<unknown>;
  43913. attachedMesh: Nullable<AbstractMesh>;
  43914. /**
  43915. * Creates a ScaleGizmo
  43916. * @param gizmoLayer The utility layer the gizmo will be added to
  43917. */
  43918. constructor(gizmoLayer?: UtilityLayerRenderer);
  43919. updateGizmoRotationToMatchAttachedMesh: boolean;
  43920. /**
  43921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43922. */
  43923. snapDistance: number;
  43924. /**
  43925. * Ratio for the scale of the gizmo (Default: 1)
  43926. */
  43927. scaleRatio: number;
  43928. /**
  43929. * Disposes of the gizmo
  43930. */
  43931. dispose(): void;
  43932. }
  43933. }
  43934. declare module BABYLON {
  43935. /**
  43936. * Single axis scale gizmo
  43937. */
  43938. export class AxisScaleGizmo extends Gizmo {
  43939. /**
  43940. * Drag behavior responsible for the gizmos dragging interactions
  43941. */
  43942. dragBehavior: PointerDragBehavior;
  43943. private _pointerObserver;
  43944. /**
  43945. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43946. */
  43947. snapDistance: number;
  43948. /**
  43949. * Event that fires each time the gizmo snaps to a new location.
  43950. * * snapDistance is the the change in distance
  43951. */
  43952. onSnapObservable: Observable<{
  43953. snapDistance: number;
  43954. }>;
  43955. /**
  43956. * If the scaling operation should be done on all axis (default: false)
  43957. */
  43958. uniformScaling: boolean;
  43959. private _isEnabled;
  43960. private _parent;
  43961. private _arrow;
  43962. private _coloredMaterial;
  43963. private _hoverMaterial;
  43964. /**
  43965. * Creates an AxisScaleGizmo
  43966. * @param gizmoLayer The utility layer the gizmo will be added to
  43967. * @param dragAxis The axis which the gizmo will be able to scale on
  43968. * @param color The color of the gizmo
  43969. */
  43970. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43971. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43972. /**
  43973. * If the gizmo is enabled
  43974. */
  43975. isEnabled: boolean;
  43976. /**
  43977. * Disposes of the gizmo
  43978. */
  43979. dispose(): void;
  43980. /**
  43981. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43982. * @param mesh The mesh to replace the default mesh of the gizmo
  43983. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43984. */
  43985. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43986. }
  43987. }
  43988. declare module BABYLON {
  43989. /**
  43990. * Bounding box gizmo
  43991. */
  43992. export class BoundingBoxGizmo extends Gizmo {
  43993. private _lineBoundingBox;
  43994. private _rotateSpheresParent;
  43995. private _scaleBoxesParent;
  43996. private _boundingDimensions;
  43997. private _renderObserver;
  43998. private _pointerObserver;
  43999. private _scaleDragSpeed;
  44000. private _tmpQuaternion;
  44001. private _tmpVector;
  44002. private _tmpRotationMatrix;
  44003. /**
  44004. * 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)
  44005. */
  44006. ignoreChildren: boolean;
  44007. /**
  44008. * 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)
  44009. */
  44010. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44011. /**
  44012. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44013. */
  44014. rotationSphereSize: number;
  44015. /**
  44016. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44017. */
  44018. scaleBoxSize: number;
  44019. /**
  44020. * 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)
  44021. */
  44022. fixedDragMeshScreenSize: boolean;
  44023. /**
  44024. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44025. */
  44026. fixedDragMeshScreenSizeDistanceFactor: number;
  44027. /**
  44028. * Fired when a rotation sphere or scale box is dragged
  44029. */
  44030. onDragStartObservable: Observable<{}>;
  44031. /**
  44032. * Fired when a scale box is dragged
  44033. */
  44034. onScaleBoxDragObservable: Observable<{}>;
  44035. /**
  44036. * Fired when a scale box drag is ended
  44037. */
  44038. onScaleBoxDragEndObservable: Observable<{}>;
  44039. /**
  44040. * Fired when a rotation sphere is dragged
  44041. */
  44042. onRotationSphereDragObservable: Observable<{}>;
  44043. /**
  44044. * Fired when a rotation sphere drag is ended
  44045. */
  44046. onRotationSphereDragEndObservable: Observable<{}>;
  44047. /**
  44048. * 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)
  44049. */
  44050. scalePivot: Nullable<Vector3>;
  44051. /**
  44052. * Mesh used as a pivot to rotate the attached mesh
  44053. */
  44054. private _anchorMesh;
  44055. private _existingMeshScale;
  44056. private _dragMesh;
  44057. private pointerDragBehavior;
  44058. private coloredMaterial;
  44059. private hoverColoredMaterial;
  44060. /**
  44061. * Sets the color of the bounding box gizmo
  44062. * @param color the color to set
  44063. */
  44064. setColor(color: Color3): void;
  44065. /**
  44066. * Creates an BoundingBoxGizmo
  44067. * @param gizmoLayer The utility layer the gizmo will be added to
  44068. * @param color The color of the gizmo
  44069. */
  44070. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44072. private _selectNode;
  44073. /**
  44074. * Updates the bounding box information for the Gizmo
  44075. */
  44076. updateBoundingBox(): void;
  44077. private _updateRotationSpheres;
  44078. private _updateScaleBoxes;
  44079. /**
  44080. * Enables rotation on the specified axis and disables rotation on the others
  44081. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44082. */
  44083. setEnabledRotationAxis(axis: string): void;
  44084. /**
  44085. * Enables/disables scaling
  44086. * @param enable if scaling should be enabled
  44087. */
  44088. setEnabledScaling(enable: boolean): void;
  44089. private _updateDummy;
  44090. /**
  44091. * Enables a pointer drag behavior on the bounding box of the gizmo
  44092. */
  44093. enableDragBehavior(): void;
  44094. /**
  44095. * Disposes of the gizmo
  44096. */
  44097. dispose(): void;
  44098. /**
  44099. * 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)
  44100. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44101. * @returns the bounding box mesh with the passed in mesh as a child
  44102. */
  44103. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44104. /**
  44105. * CustomMeshes are not supported by this gizmo
  44106. * @param mesh The mesh to replace the default mesh of the gizmo
  44107. */
  44108. setCustomMesh(mesh: Mesh): void;
  44109. }
  44110. }
  44111. declare module BABYLON {
  44112. /**
  44113. * Single plane rotation gizmo
  44114. */
  44115. export class PlaneRotationGizmo extends Gizmo {
  44116. /**
  44117. * Drag behavior responsible for the gizmos dragging interactions
  44118. */
  44119. dragBehavior: PointerDragBehavior;
  44120. private _pointerObserver;
  44121. /**
  44122. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44123. */
  44124. snapDistance: number;
  44125. /**
  44126. * Event that fires each time the gizmo snaps to a new location.
  44127. * * snapDistance is the the change in distance
  44128. */
  44129. onSnapObservable: Observable<{
  44130. snapDistance: number;
  44131. }>;
  44132. private _isEnabled;
  44133. private _parent;
  44134. /**
  44135. * Creates a PlaneRotationGizmo
  44136. * @param gizmoLayer The utility layer the gizmo will be added to
  44137. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44138. * @param color The color of the gizmo
  44139. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44140. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44141. */
  44142. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44143. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44144. /**
  44145. * If the gizmo is enabled
  44146. */
  44147. isEnabled: boolean;
  44148. /**
  44149. * Disposes of the gizmo
  44150. */
  44151. dispose(): void;
  44152. }
  44153. }
  44154. declare module BABYLON {
  44155. /**
  44156. * Gizmo that enables rotating a mesh along 3 axis
  44157. */
  44158. export class RotationGizmo extends Gizmo {
  44159. /**
  44160. * Internal gizmo used for interactions on the x axis
  44161. */
  44162. xGizmo: PlaneRotationGizmo;
  44163. /**
  44164. * Internal gizmo used for interactions on the y axis
  44165. */
  44166. yGizmo: PlaneRotationGizmo;
  44167. /**
  44168. * Internal gizmo used for interactions on the z axis
  44169. */
  44170. zGizmo: PlaneRotationGizmo;
  44171. /** Fires an event when any of it's sub gizmos are dragged */
  44172. onDragStartObservable: Observable<unknown>;
  44173. /** Fires an event when any of it's sub gizmos are released from dragging */
  44174. onDragEndObservable: Observable<unknown>;
  44175. private _meshAttached;
  44176. attachedMesh: Nullable<AbstractMesh>;
  44177. /**
  44178. * Creates a RotationGizmo
  44179. * @param gizmoLayer The utility layer the gizmo will be added to
  44180. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44181. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44182. */
  44183. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44184. updateGizmoRotationToMatchAttachedMesh: boolean;
  44185. /**
  44186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44187. */
  44188. snapDistance: number;
  44189. /**
  44190. * Ratio for the scale of the gizmo (Default: 1)
  44191. */
  44192. scaleRatio: number;
  44193. /**
  44194. * Disposes of the gizmo
  44195. */
  44196. dispose(): void;
  44197. /**
  44198. * CustomMeshes are not supported by this gizmo
  44199. * @param mesh The mesh to replace the default mesh of the gizmo
  44200. */
  44201. setCustomMesh(mesh: Mesh): void;
  44202. }
  44203. }
  44204. declare module BABYLON {
  44205. /**
  44206. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44207. */
  44208. export class GizmoManager implements IDisposable {
  44209. private scene;
  44210. /**
  44211. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44212. */
  44213. gizmos: {
  44214. positionGizmo: Nullable<PositionGizmo>;
  44215. rotationGizmo: Nullable<RotationGizmo>;
  44216. scaleGizmo: Nullable<ScaleGizmo>;
  44217. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44218. };
  44219. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44220. clearGizmoOnEmptyPointerEvent: boolean;
  44221. /** Fires an event when the manager is attached to a mesh */
  44222. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44223. private _gizmosEnabled;
  44224. private _pointerObserver;
  44225. private _attachedMesh;
  44226. private _boundingBoxColor;
  44227. private _defaultUtilityLayer;
  44228. private _defaultKeepDepthUtilityLayer;
  44229. /**
  44230. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44231. */
  44232. boundingBoxDragBehavior: SixDofDragBehavior;
  44233. /**
  44234. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44235. */
  44236. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44237. /**
  44238. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44239. */
  44240. usePointerToAttachGizmos: boolean;
  44241. /**
  44242. * Utility layer that the bounding box gizmo belongs to
  44243. */
  44244. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44245. /**
  44246. * Utility layer that all gizmos besides bounding box belong to
  44247. */
  44248. readonly utilityLayer: UtilityLayerRenderer;
  44249. /**
  44250. * Instatiates a gizmo manager
  44251. * @param scene the scene to overlay the gizmos on top of
  44252. */
  44253. constructor(scene: Scene);
  44254. /**
  44255. * Attaches a set of gizmos to the specified mesh
  44256. * @param mesh The mesh the gizmo's should be attached to
  44257. */
  44258. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44259. /**
  44260. * If the position gizmo is enabled
  44261. */
  44262. positionGizmoEnabled: boolean;
  44263. /**
  44264. * If the rotation gizmo is enabled
  44265. */
  44266. rotationGizmoEnabled: boolean;
  44267. /**
  44268. * If the scale gizmo is enabled
  44269. */
  44270. scaleGizmoEnabled: boolean;
  44271. /**
  44272. * If the boundingBox gizmo is enabled
  44273. */
  44274. boundingBoxGizmoEnabled: boolean;
  44275. /**
  44276. * Disposes of the gizmo manager
  44277. */
  44278. dispose(): void;
  44279. }
  44280. }
  44281. declare module BABYLON {
  44282. /**
  44283. * A directional light is defined by a direction (what a surprise!).
  44284. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44285. * 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.
  44286. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44287. */
  44288. export class DirectionalLight extends ShadowLight {
  44289. private _shadowFrustumSize;
  44290. /**
  44291. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44292. */
  44293. /**
  44294. * Specifies a fix frustum size for the shadow generation.
  44295. */
  44296. shadowFrustumSize: number;
  44297. private _shadowOrthoScale;
  44298. /**
  44299. * Gets the shadow projection scale against the optimal computed one.
  44300. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44301. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44302. */
  44303. /**
  44304. * Sets the shadow projection scale against the optimal computed one.
  44305. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44306. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44307. */
  44308. shadowOrthoScale: number;
  44309. /**
  44310. * Automatically compute the projection matrix to best fit (including all the casters)
  44311. * on each frame.
  44312. */
  44313. autoUpdateExtends: boolean;
  44314. private _orthoLeft;
  44315. private _orthoRight;
  44316. private _orthoTop;
  44317. private _orthoBottom;
  44318. /**
  44319. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44320. * The directional light is emitted from everywhere in the given direction.
  44321. * It can cast shadows.
  44322. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44323. * @param name The friendly name of the light
  44324. * @param direction The direction of the light
  44325. * @param scene The scene the light belongs to
  44326. */
  44327. constructor(name: string, direction: Vector3, scene: Scene);
  44328. /**
  44329. * Returns the string "DirectionalLight".
  44330. * @return The class name
  44331. */
  44332. getClassName(): string;
  44333. /**
  44334. * Returns the integer 1.
  44335. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44336. */
  44337. getTypeID(): number;
  44338. /**
  44339. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44340. * Returns the DirectionalLight Shadow projection matrix.
  44341. */
  44342. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44343. /**
  44344. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44345. * Returns the DirectionalLight Shadow projection matrix.
  44346. */
  44347. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44348. /**
  44349. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44350. * Returns the DirectionalLight Shadow projection matrix.
  44351. */
  44352. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44353. protected _buildUniformLayout(): void;
  44354. /**
  44355. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44356. * @param effect The effect to update
  44357. * @param lightIndex The index of the light in the effect to update
  44358. * @returns The directional light
  44359. */
  44360. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44361. /**
  44362. * Gets the minZ used for shadow according to both the scene and the light.
  44363. *
  44364. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44365. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44366. * @param activeCamera The camera we are returning the min for
  44367. * @returns the depth min z
  44368. */
  44369. getDepthMinZ(activeCamera: Camera): number;
  44370. /**
  44371. * Gets the maxZ used for shadow according to both the scene and the light.
  44372. *
  44373. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44374. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44375. * @param activeCamera The camera we are returning the max for
  44376. * @returns the depth max z
  44377. */
  44378. getDepthMaxZ(activeCamera: Camera): number;
  44379. /**
  44380. * Prepares the list of defines specific to the light type.
  44381. * @param defines the list of defines
  44382. * @param lightIndex defines the index of the light for the effect
  44383. */
  44384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44385. }
  44386. }
  44387. declare module BABYLON {
  44388. /**
  44389. * Class containing static functions to help procedurally build meshes
  44390. */
  44391. export class HemisphereBuilder {
  44392. /**
  44393. * Creates a hemisphere mesh
  44394. * @param name defines the name of the mesh
  44395. * @param options defines the options used to create the mesh
  44396. * @param scene defines the hosting scene
  44397. * @returns the hemisphere mesh
  44398. */
  44399. static CreateHemisphere(name: string, options: {
  44400. segments?: number;
  44401. diameter?: number;
  44402. sideOrientation?: number;
  44403. }, scene: any): Mesh;
  44404. }
  44405. }
  44406. declare module BABYLON {
  44407. /**
  44408. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44409. * These values define a cone of light starting from the position, emitting toward the direction.
  44410. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44411. * and the exponent defines the speed of the decay of the light with distance (reach).
  44412. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44413. */
  44414. export class SpotLight extends ShadowLight {
  44415. private _angle;
  44416. private _innerAngle;
  44417. private _cosHalfAngle;
  44418. private _lightAngleScale;
  44419. private _lightAngleOffset;
  44420. /**
  44421. * Gets the cone angle of the spot light in Radians.
  44422. */
  44423. /**
  44424. * Sets the cone angle of the spot light in Radians.
  44425. */
  44426. angle: number;
  44427. /**
  44428. * Only used in gltf falloff mode, this defines the angle where
  44429. * the directional falloff will start before cutting at angle which could be seen
  44430. * as outer angle.
  44431. */
  44432. /**
  44433. * Only used in gltf falloff mode, this defines the angle where
  44434. * the directional falloff will start before cutting at angle which could be seen
  44435. * as outer angle.
  44436. */
  44437. innerAngle: number;
  44438. private _shadowAngleScale;
  44439. /**
  44440. * Allows scaling the angle of the light for shadow generation only.
  44441. */
  44442. /**
  44443. * Allows scaling the angle of the light for shadow generation only.
  44444. */
  44445. shadowAngleScale: number;
  44446. /**
  44447. * The light decay speed with the distance from the emission spot.
  44448. */
  44449. exponent: number;
  44450. private _projectionTextureMatrix;
  44451. /**
  44452. * Allows reading the projecton texture
  44453. */
  44454. readonly projectionTextureMatrix: Matrix;
  44455. protected _projectionTextureLightNear: number;
  44456. /**
  44457. * Gets the near clip of the Spotlight for texture projection.
  44458. */
  44459. /**
  44460. * Sets the near clip of the Spotlight for texture projection.
  44461. */
  44462. projectionTextureLightNear: number;
  44463. protected _projectionTextureLightFar: number;
  44464. /**
  44465. * Gets the far clip of the Spotlight for texture projection.
  44466. */
  44467. /**
  44468. * Sets the far clip of the Spotlight for texture projection.
  44469. */
  44470. projectionTextureLightFar: number;
  44471. protected _projectionTextureUpDirection: Vector3;
  44472. /**
  44473. * Gets the Up vector of the Spotlight for texture projection.
  44474. */
  44475. /**
  44476. * Sets the Up vector of the Spotlight for texture projection.
  44477. */
  44478. projectionTextureUpDirection: Vector3;
  44479. private _projectionTexture;
  44480. /**
  44481. * Gets the projection texture of the light.
  44482. */
  44483. /**
  44484. * Sets the projection texture of the light.
  44485. */
  44486. projectionTexture: Nullable<BaseTexture>;
  44487. private _projectionTextureViewLightDirty;
  44488. private _projectionTextureProjectionLightDirty;
  44489. private _projectionTextureDirty;
  44490. private _projectionTextureViewTargetVector;
  44491. private _projectionTextureViewLightMatrix;
  44492. private _projectionTextureProjectionLightMatrix;
  44493. private _projectionTextureScalingMatrix;
  44494. /**
  44495. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44496. * It can cast shadows.
  44497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44498. * @param name The light friendly name
  44499. * @param position The position of the spot light in the scene
  44500. * @param direction The direction of the light in the scene
  44501. * @param angle The cone angle of the light in Radians
  44502. * @param exponent The light decay speed with the distance from the emission spot
  44503. * @param scene The scene the lights belongs to
  44504. */
  44505. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44506. /**
  44507. * Returns the string "SpotLight".
  44508. * @returns the class name
  44509. */
  44510. getClassName(): string;
  44511. /**
  44512. * Returns the integer 2.
  44513. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44514. */
  44515. getTypeID(): number;
  44516. /**
  44517. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44518. */
  44519. protected _setDirection(value: Vector3): void;
  44520. /**
  44521. * Overrides the position setter to recompute the projection texture view light Matrix.
  44522. */
  44523. protected _setPosition(value: Vector3): void;
  44524. /**
  44525. * 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.
  44526. * Returns the SpotLight.
  44527. */
  44528. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44529. protected _computeProjectionTextureViewLightMatrix(): void;
  44530. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44531. /**
  44532. * Main function for light texture projection matrix computing.
  44533. */
  44534. protected _computeProjectionTextureMatrix(): void;
  44535. protected _buildUniformLayout(): void;
  44536. private _computeAngleValues;
  44537. /**
  44538. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44539. * @param effect The effect to update
  44540. * @param lightIndex The index of the light in the effect to update
  44541. * @returns The spot light
  44542. */
  44543. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44544. /**
  44545. * Disposes the light and the associated resources.
  44546. */
  44547. dispose(): void;
  44548. /**
  44549. * Prepares the list of defines specific to the light type.
  44550. * @param defines the list of defines
  44551. * @param lightIndex defines the index of the light for the effect
  44552. */
  44553. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44554. }
  44555. }
  44556. declare module BABYLON {
  44557. /**
  44558. * Gizmo that enables viewing a light
  44559. */
  44560. export class LightGizmo extends Gizmo {
  44561. private _lightMesh;
  44562. private _material;
  44563. private cachedPosition;
  44564. private cachedForward;
  44565. /**
  44566. * Creates a LightGizmo
  44567. * @param gizmoLayer The utility layer the gizmo will be added to
  44568. */
  44569. constructor(gizmoLayer?: UtilityLayerRenderer);
  44570. private _light;
  44571. /**
  44572. * The light that the gizmo is attached to
  44573. */
  44574. light: Nullable<Light>;
  44575. /**
  44576. * @hidden
  44577. * Updates the gizmo to match the attached mesh's position/rotation
  44578. */
  44579. protected _update(): void;
  44580. private static _Scale;
  44581. /**
  44582. * Creates the lines for a light mesh
  44583. */
  44584. private static _createLightLines;
  44585. /**
  44586. * Disposes of the light gizmo
  44587. */
  44588. dispose(): void;
  44589. private static _CreateHemisphericLightMesh;
  44590. private static _CreatePointLightMesh;
  44591. private static _CreateSpotLightMesh;
  44592. private static _CreateDirectionalLightMesh;
  44593. }
  44594. }
  44595. declare module BABYLON {
  44596. /** @hidden */
  44597. export var backgroundFragmentDeclaration: {
  44598. name: string;
  44599. shader: string;
  44600. };
  44601. }
  44602. declare module BABYLON {
  44603. /** @hidden */
  44604. export var backgroundUboDeclaration: {
  44605. name: string;
  44606. shader: string;
  44607. };
  44608. }
  44609. declare module BABYLON {
  44610. /** @hidden */
  44611. export var backgroundPixelShader: {
  44612. name: string;
  44613. shader: string;
  44614. };
  44615. }
  44616. declare module BABYLON {
  44617. /** @hidden */
  44618. export var backgroundVertexDeclaration: {
  44619. name: string;
  44620. shader: string;
  44621. };
  44622. }
  44623. declare module BABYLON {
  44624. /** @hidden */
  44625. export var backgroundVertexShader: {
  44626. name: string;
  44627. shader: string;
  44628. };
  44629. }
  44630. declare module BABYLON {
  44631. /**
  44632. * Background material used to create an efficient environement around your scene.
  44633. */
  44634. export class BackgroundMaterial extends PushMaterial {
  44635. /**
  44636. * Standard reflectance value at parallel view angle.
  44637. */
  44638. static StandardReflectance0: number;
  44639. /**
  44640. * Standard reflectance value at grazing angle.
  44641. */
  44642. static StandardReflectance90: number;
  44643. protected _primaryColor: Color3;
  44644. /**
  44645. * Key light Color (multiply against the environement texture)
  44646. */
  44647. primaryColor: Color3;
  44648. protected __perceptualColor: Nullable<Color3>;
  44649. /**
  44650. * Experimental Internal Use Only.
  44651. *
  44652. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44653. * This acts as a helper to set the primary color to a more "human friendly" value.
  44654. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44655. * output color as close as possible from the chosen value.
  44656. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44657. * part of lighting setup.)
  44658. */
  44659. _perceptualColor: Nullable<Color3>;
  44660. protected _primaryColorShadowLevel: float;
  44661. /**
  44662. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44663. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44664. */
  44665. primaryColorShadowLevel: float;
  44666. protected _primaryColorHighlightLevel: float;
  44667. /**
  44668. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44669. * The primary color is used at the level chosen to define what the white area would look.
  44670. */
  44671. primaryColorHighlightLevel: float;
  44672. protected _reflectionTexture: Nullable<BaseTexture>;
  44673. /**
  44674. * Reflection Texture used in the material.
  44675. * Should be author in a specific way for the best result (refer to the documentation).
  44676. */
  44677. reflectionTexture: Nullable<BaseTexture>;
  44678. protected _reflectionBlur: float;
  44679. /**
  44680. * Reflection Texture level of blur.
  44681. *
  44682. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44683. * texture twice.
  44684. */
  44685. reflectionBlur: float;
  44686. protected _diffuseTexture: Nullable<BaseTexture>;
  44687. /**
  44688. * Diffuse Texture used in the material.
  44689. * Should be author in a specific way for the best result (refer to the documentation).
  44690. */
  44691. diffuseTexture: Nullable<BaseTexture>;
  44692. protected _shadowLights: Nullable<IShadowLight[]>;
  44693. /**
  44694. * Specify the list of lights casting shadow on the material.
  44695. * All scene shadow lights will be included if null.
  44696. */
  44697. shadowLights: Nullable<IShadowLight[]>;
  44698. protected _shadowLevel: float;
  44699. /**
  44700. * Helps adjusting the shadow to a softer level if required.
  44701. * 0 means black shadows and 1 means no shadows.
  44702. */
  44703. shadowLevel: float;
  44704. protected _sceneCenter: Vector3;
  44705. /**
  44706. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44707. * It is usually zero but might be interesting to modify according to your setup.
  44708. */
  44709. sceneCenter: Vector3;
  44710. protected _opacityFresnel: boolean;
  44711. /**
  44712. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44713. * This helps ensuring a nice transition when the camera goes under the ground.
  44714. */
  44715. opacityFresnel: boolean;
  44716. protected _reflectionFresnel: boolean;
  44717. /**
  44718. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44719. * This helps adding a mirror texture on the ground.
  44720. */
  44721. reflectionFresnel: boolean;
  44722. protected _reflectionFalloffDistance: number;
  44723. /**
  44724. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44725. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44726. */
  44727. reflectionFalloffDistance: number;
  44728. protected _reflectionAmount: number;
  44729. /**
  44730. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44731. */
  44732. reflectionAmount: number;
  44733. protected _reflectionReflectance0: number;
  44734. /**
  44735. * This specifies the weight of the reflection at grazing angle.
  44736. */
  44737. reflectionReflectance0: number;
  44738. protected _reflectionReflectance90: number;
  44739. /**
  44740. * This specifies the weight of the reflection at a perpendicular point of view.
  44741. */
  44742. reflectionReflectance90: number;
  44743. /**
  44744. * Sets the reflection reflectance fresnel values according to the default standard
  44745. * empirically know to work well :-)
  44746. */
  44747. reflectionStandardFresnelWeight: number;
  44748. protected _useRGBColor: boolean;
  44749. /**
  44750. * Helps to directly use the maps channels instead of their level.
  44751. */
  44752. useRGBColor: boolean;
  44753. protected _enableNoise: boolean;
  44754. /**
  44755. * This helps reducing the banding effect that could occur on the background.
  44756. */
  44757. enableNoise: boolean;
  44758. /**
  44759. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44760. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44761. * Recommended to be keep at 1.0 except for special cases.
  44762. */
  44763. fovMultiplier: number;
  44764. private _fovMultiplier;
  44765. /**
  44766. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44767. */
  44768. useEquirectangularFOV: boolean;
  44769. private _maxSimultaneousLights;
  44770. /**
  44771. * Number of Simultaneous lights allowed on the material.
  44772. */
  44773. maxSimultaneousLights: int;
  44774. /**
  44775. * Default configuration related to image processing available in the Background Material.
  44776. */
  44777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44778. /**
  44779. * Keep track of the image processing observer to allow dispose and replace.
  44780. */
  44781. private _imageProcessingObserver;
  44782. /**
  44783. * Attaches a new image processing configuration to the PBR Material.
  44784. * @param configuration (if null the scene configuration will be use)
  44785. */
  44786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44787. /**
  44788. * Gets the image processing configuration used either in this material.
  44789. */
  44790. /**
  44791. * Sets the Default image processing configuration used either in the this material.
  44792. *
  44793. * If sets to null, the scene one is in use.
  44794. */
  44795. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44796. /**
  44797. * Gets wether the color curves effect is enabled.
  44798. */
  44799. /**
  44800. * Sets wether the color curves effect is enabled.
  44801. */
  44802. cameraColorCurvesEnabled: boolean;
  44803. /**
  44804. * Gets wether the color grading effect is enabled.
  44805. */
  44806. /**
  44807. * Gets wether the color grading effect is enabled.
  44808. */
  44809. cameraColorGradingEnabled: boolean;
  44810. /**
  44811. * Gets wether tonemapping is enabled or not.
  44812. */
  44813. /**
  44814. * Sets wether tonemapping is enabled or not
  44815. */
  44816. cameraToneMappingEnabled: boolean;
  44817. /**
  44818. * The camera exposure used on this material.
  44819. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44820. * This corresponds to a photographic exposure.
  44821. */
  44822. /**
  44823. * The camera exposure used on this material.
  44824. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44825. * This corresponds to a photographic exposure.
  44826. */
  44827. cameraExposure: float;
  44828. /**
  44829. * Gets The camera contrast used on this material.
  44830. */
  44831. /**
  44832. * Sets The camera contrast used on this material.
  44833. */
  44834. cameraContrast: float;
  44835. /**
  44836. * Gets the Color Grading 2D Lookup Texture.
  44837. */
  44838. /**
  44839. * Sets the Color Grading 2D Lookup Texture.
  44840. */
  44841. cameraColorGradingTexture: Nullable<BaseTexture>;
  44842. /**
  44843. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44844. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44845. * 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;
  44846. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44847. */
  44848. /**
  44849. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44850. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44851. * 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;
  44852. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44853. */
  44854. cameraColorCurves: Nullable<ColorCurves>;
  44855. /**
  44856. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44857. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44858. */
  44859. switchToBGR: boolean;
  44860. private _renderTargets;
  44861. private _reflectionControls;
  44862. private _white;
  44863. private _primaryShadowColor;
  44864. private _primaryHighlightColor;
  44865. /**
  44866. * Instantiates a Background Material in the given scene
  44867. * @param name The friendly name of the material
  44868. * @param scene The scene to add the material to
  44869. */
  44870. constructor(name: string, scene: Scene);
  44871. /**
  44872. * Gets a boolean indicating that current material needs to register RTT
  44873. */
  44874. readonly hasRenderTargetTextures: boolean;
  44875. /**
  44876. * The entire material has been created in order to prevent overdraw.
  44877. * @returns false
  44878. */
  44879. needAlphaTesting(): boolean;
  44880. /**
  44881. * The entire material has been created in order to prevent overdraw.
  44882. * @returns true if blending is enable
  44883. */
  44884. needAlphaBlending(): boolean;
  44885. /**
  44886. * Checks wether the material is ready to be rendered for a given mesh.
  44887. * @param mesh The mesh to render
  44888. * @param subMesh The submesh to check against
  44889. * @param useInstances Specify wether or not the material is used with instances
  44890. * @returns true if all the dependencies are ready (Textures, Effects...)
  44891. */
  44892. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44893. /**
  44894. * Compute the primary color according to the chosen perceptual color.
  44895. */
  44896. private _computePrimaryColorFromPerceptualColor;
  44897. /**
  44898. * Compute the highlights and shadow colors according to their chosen levels.
  44899. */
  44900. private _computePrimaryColors;
  44901. /**
  44902. * Build the uniform buffer used in the material.
  44903. */
  44904. buildUniformLayout(): void;
  44905. /**
  44906. * Unbind the material.
  44907. */
  44908. unbind(): void;
  44909. /**
  44910. * Bind only the world matrix to the material.
  44911. * @param world The world matrix to bind.
  44912. */
  44913. bindOnlyWorldMatrix(world: Matrix): void;
  44914. /**
  44915. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44916. * @param world The world matrix to bind.
  44917. * @param subMesh The submesh to bind for.
  44918. */
  44919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44920. /**
  44921. * Dispose the material.
  44922. * @param forceDisposeEffect Force disposal of the associated effect.
  44923. * @param forceDisposeTextures Force disposal of the associated textures.
  44924. */
  44925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44926. /**
  44927. * Clones the material.
  44928. * @param name The cloned name.
  44929. * @returns The cloned material.
  44930. */
  44931. clone(name: string): BackgroundMaterial;
  44932. /**
  44933. * Serializes the current material to its JSON representation.
  44934. * @returns The JSON representation.
  44935. */
  44936. serialize(): any;
  44937. /**
  44938. * Gets the class name of the material
  44939. * @returns "BackgroundMaterial"
  44940. */
  44941. getClassName(): string;
  44942. /**
  44943. * Parse a JSON input to create back a background material.
  44944. * @param source The JSON data to parse
  44945. * @param scene The scene to create the parsed material in
  44946. * @param rootUrl The root url of the assets the material depends upon
  44947. * @returns the instantiated BackgroundMaterial.
  44948. */
  44949. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44950. }
  44951. }
  44952. declare module BABYLON {
  44953. /**
  44954. * Represents the different options available during the creation of
  44955. * a Environment helper.
  44956. *
  44957. * This can control the default ground, skybox and image processing setup of your scene.
  44958. */
  44959. export interface IEnvironmentHelperOptions {
  44960. /**
  44961. * Specifies wether or not to create a ground.
  44962. * True by default.
  44963. */
  44964. createGround: boolean;
  44965. /**
  44966. * Specifies the ground size.
  44967. * 15 by default.
  44968. */
  44969. groundSize: number;
  44970. /**
  44971. * The texture used on the ground for the main color.
  44972. * Comes from the BabylonJS CDN by default.
  44973. *
  44974. * Remarks: Can be either a texture or a url.
  44975. */
  44976. groundTexture: string | BaseTexture;
  44977. /**
  44978. * The color mixed in the ground texture by default.
  44979. * BabylonJS clearColor by default.
  44980. */
  44981. groundColor: Color3;
  44982. /**
  44983. * Specifies the ground opacity.
  44984. * 1 by default.
  44985. */
  44986. groundOpacity: number;
  44987. /**
  44988. * Enables the ground to receive shadows.
  44989. * True by default.
  44990. */
  44991. enableGroundShadow: boolean;
  44992. /**
  44993. * Helps preventing the shadow to be fully black on the ground.
  44994. * 0.5 by default.
  44995. */
  44996. groundShadowLevel: number;
  44997. /**
  44998. * Creates a mirror texture attach to the ground.
  44999. * false by default.
  45000. */
  45001. enableGroundMirror: boolean;
  45002. /**
  45003. * Specifies the ground mirror size ratio.
  45004. * 0.3 by default as the default kernel is 64.
  45005. */
  45006. groundMirrorSizeRatio: number;
  45007. /**
  45008. * Specifies the ground mirror blur kernel size.
  45009. * 64 by default.
  45010. */
  45011. groundMirrorBlurKernel: number;
  45012. /**
  45013. * Specifies the ground mirror visibility amount.
  45014. * 1 by default
  45015. */
  45016. groundMirrorAmount: number;
  45017. /**
  45018. * Specifies the ground mirror reflectance weight.
  45019. * This uses the standard weight of the background material to setup the fresnel effect
  45020. * of the mirror.
  45021. * 1 by default.
  45022. */
  45023. groundMirrorFresnelWeight: number;
  45024. /**
  45025. * Specifies the ground mirror Falloff distance.
  45026. * This can helps reducing the size of the reflection.
  45027. * 0 by Default.
  45028. */
  45029. groundMirrorFallOffDistance: number;
  45030. /**
  45031. * Specifies the ground mirror texture type.
  45032. * Unsigned Int by Default.
  45033. */
  45034. groundMirrorTextureType: number;
  45035. /**
  45036. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45037. * the shown objects.
  45038. */
  45039. groundYBias: number;
  45040. /**
  45041. * Specifies wether or not to create a skybox.
  45042. * True by default.
  45043. */
  45044. createSkybox: boolean;
  45045. /**
  45046. * Specifies the skybox size.
  45047. * 20 by default.
  45048. */
  45049. skyboxSize: number;
  45050. /**
  45051. * The texture used on the skybox for the main color.
  45052. * Comes from the BabylonJS CDN by default.
  45053. *
  45054. * Remarks: Can be either a texture or a url.
  45055. */
  45056. skyboxTexture: string | BaseTexture;
  45057. /**
  45058. * The color mixed in the skybox texture by default.
  45059. * BabylonJS clearColor by default.
  45060. */
  45061. skyboxColor: Color3;
  45062. /**
  45063. * The background rotation around the Y axis of the scene.
  45064. * This helps aligning the key lights of your scene with the background.
  45065. * 0 by default.
  45066. */
  45067. backgroundYRotation: number;
  45068. /**
  45069. * Compute automatically the size of the elements to best fit with the scene.
  45070. */
  45071. sizeAuto: boolean;
  45072. /**
  45073. * Default position of the rootMesh if autoSize is not true.
  45074. */
  45075. rootPosition: Vector3;
  45076. /**
  45077. * Sets up the image processing in the scene.
  45078. * true by default.
  45079. */
  45080. setupImageProcessing: boolean;
  45081. /**
  45082. * The texture used as your environment texture in the scene.
  45083. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45084. *
  45085. * Remarks: Can be either a texture or a url.
  45086. */
  45087. environmentTexture: string | BaseTexture;
  45088. /**
  45089. * The value of the exposure to apply to the scene.
  45090. * 0.6 by default if setupImageProcessing is true.
  45091. */
  45092. cameraExposure: number;
  45093. /**
  45094. * The value of the contrast to apply to the scene.
  45095. * 1.6 by default if setupImageProcessing is true.
  45096. */
  45097. cameraContrast: number;
  45098. /**
  45099. * Specifies wether or not tonemapping should be enabled in the scene.
  45100. * true by default if setupImageProcessing is true.
  45101. */
  45102. toneMappingEnabled: boolean;
  45103. }
  45104. /**
  45105. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45106. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45107. * It also helps with the default setup of your imageProcessing configuration.
  45108. */
  45109. export class EnvironmentHelper {
  45110. /**
  45111. * Default ground texture URL.
  45112. */
  45113. private static _groundTextureCDNUrl;
  45114. /**
  45115. * Default skybox texture URL.
  45116. */
  45117. private static _skyboxTextureCDNUrl;
  45118. /**
  45119. * Default environment texture URL.
  45120. */
  45121. private static _environmentTextureCDNUrl;
  45122. /**
  45123. * Creates the default options for the helper.
  45124. */
  45125. private static _getDefaultOptions;
  45126. private _rootMesh;
  45127. /**
  45128. * Gets the root mesh created by the helper.
  45129. */
  45130. readonly rootMesh: Mesh;
  45131. private _skybox;
  45132. /**
  45133. * Gets the skybox created by the helper.
  45134. */
  45135. readonly skybox: Nullable<Mesh>;
  45136. private _skyboxTexture;
  45137. /**
  45138. * Gets the skybox texture created by the helper.
  45139. */
  45140. readonly skyboxTexture: Nullable<BaseTexture>;
  45141. private _skyboxMaterial;
  45142. /**
  45143. * Gets the skybox material created by the helper.
  45144. */
  45145. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45146. private _ground;
  45147. /**
  45148. * Gets the ground mesh created by the helper.
  45149. */
  45150. readonly ground: Nullable<Mesh>;
  45151. private _groundTexture;
  45152. /**
  45153. * Gets the ground texture created by the helper.
  45154. */
  45155. readonly groundTexture: Nullable<BaseTexture>;
  45156. private _groundMirror;
  45157. /**
  45158. * Gets the ground mirror created by the helper.
  45159. */
  45160. readonly groundMirror: Nullable<MirrorTexture>;
  45161. /**
  45162. * Gets the ground mirror render list to helps pushing the meshes
  45163. * you wish in the ground reflection.
  45164. */
  45165. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45166. private _groundMaterial;
  45167. /**
  45168. * Gets the ground material created by the helper.
  45169. */
  45170. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45171. /**
  45172. * Stores the creation options.
  45173. */
  45174. private readonly _scene;
  45175. private _options;
  45176. /**
  45177. * This observable will be notified with any error during the creation of the environment,
  45178. * mainly texture creation errors.
  45179. */
  45180. onErrorObservable: Observable<{
  45181. message?: string;
  45182. exception?: any;
  45183. }>;
  45184. /**
  45185. * constructor
  45186. * @param options Defines the options we want to customize the helper
  45187. * @param scene The scene to add the material to
  45188. */
  45189. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45190. /**
  45191. * Updates the background according to the new options
  45192. * @param options
  45193. */
  45194. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45195. /**
  45196. * Sets the primary color of all the available elements.
  45197. * @param color the main color to affect to the ground and the background
  45198. */
  45199. setMainColor(color: Color3): void;
  45200. /**
  45201. * Setup the image processing according to the specified options.
  45202. */
  45203. private _setupImageProcessing;
  45204. /**
  45205. * Setup the environment texture according to the specified options.
  45206. */
  45207. private _setupEnvironmentTexture;
  45208. /**
  45209. * Setup the background according to the specified options.
  45210. */
  45211. private _setupBackground;
  45212. /**
  45213. * Get the scene sizes according to the setup.
  45214. */
  45215. private _getSceneSize;
  45216. /**
  45217. * Setup the ground according to the specified options.
  45218. */
  45219. private _setupGround;
  45220. /**
  45221. * Setup the ground material according to the specified options.
  45222. */
  45223. private _setupGroundMaterial;
  45224. /**
  45225. * Setup the ground diffuse texture according to the specified options.
  45226. */
  45227. private _setupGroundDiffuseTexture;
  45228. /**
  45229. * Setup the ground mirror texture according to the specified options.
  45230. */
  45231. private _setupGroundMirrorTexture;
  45232. /**
  45233. * Setup the ground to receive the mirror texture.
  45234. */
  45235. private _setupMirrorInGroundMaterial;
  45236. /**
  45237. * Setup the skybox according to the specified options.
  45238. */
  45239. private _setupSkybox;
  45240. /**
  45241. * Setup the skybox material according to the specified options.
  45242. */
  45243. private _setupSkyboxMaterial;
  45244. /**
  45245. * Setup the skybox reflection texture according to the specified options.
  45246. */
  45247. private _setupSkyboxReflectionTexture;
  45248. private _errorHandler;
  45249. /**
  45250. * Dispose all the elements created by the Helper.
  45251. */
  45252. dispose(): void;
  45253. }
  45254. }
  45255. declare module BABYLON {
  45256. /**
  45257. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45258. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45259. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45260. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45261. */
  45262. export class PhotoDome extends TransformNode {
  45263. /**
  45264. * Define the image as a Monoscopic panoramic 360 image.
  45265. */
  45266. static readonly MODE_MONOSCOPIC: number;
  45267. /**
  45268. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45269. */
  45270. static readonly MODE_TOPBOTTOM: number;
  45271. /**
  45272. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45273. */
  45274. static readonly MODE_SIDEBYSIDE: number;
  45275. private _useDirectMapping;
  45276. /**
  45277. * The texture being displayed on the sphere
  45278. */
  45279. protected _photoTexture: Texture;
  45280. /**
  45281. * Gets or sets the texture being displayed on the sphere
  45282. */
  45283. photoTexture: Texture;
  45284. /**
  45285. * Observable raised when an error occured while loading the 360 image
  45286. */
  45287. onLoadErrorObservable: Observable<string>;
  45288. /**
  45289. * The skybox material
  45290. */
  45291. protected _material: BackgroundMaterial;
  45292. /**
  45293. * The surface used for the skybox
  45294. */
  45295. protected _mesh: Mesh;
  45296. /**
  45297. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45298. * Also see the options.resolution property.
  45299. */
  45300. fovMultiplier: number;
  45301. private _imageMode;
  45302. /**
  45303. * Gets or set the current video mode for the video. It can be:
  45304. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45305. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45306. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45307. */
  45308. imageMode: number;
  45309. /**
  45310. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45311. * @param name Element's name, child elements will append suffixes for their own names.
  45312. * @param urlsOfPhoto defines the url of the photo to display
  45313. * @param options defines an object containing optional or exposed sub element properties
  45314. * @param onError defines a callback called when an error occured while loading the texture
  45315. */
  45316. constructor(name: string, urlOfPhoto: string, options: {
  45317. resolution?: number;
  45318. size?: number;
  45319. useDirectMapping?: boolean;
  45320. faceForward?: boolean;
  45321. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45322. private _onBeforeCameraRenderObserver;
  45323. private _changeImageMode;
  45324. /**
  45325. * Releases resources associated with this node.
  45326. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45327. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45328. */
  45329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45330. }
  45331. }
  45332. declare module BABYLON {
  45333. /** @hidden */
  45334. export var rgbdDecodePixelShader: {
  45335. name: string;
  45336. shader: string;
  45337. };
  45338. }
  45339. declare module BABYLON {
  45340. /**
  45341. * Class used to host texture specific utilities
  45342. */
  45343. export class BRDFTextureTools {
  45344. /**
  45345. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45346. * @param texture the texture to expand.
  45347. */
  45348. private static _ExpandDefaultBRDFTexture;
  45349. /**
  45350. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45351. * @param scene defines the hosting scene
  45352. * @returns the environment BRDF texture
  45353. */
  45354. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45355. private static _environmentBRDFBase64Texture;
  45356. }
  45357. }
  45358. declare module BABYLON {
  45359. /**
  45360. * @hidden
  45361. */
  45362. export interface IMaterialClearCoatDefines {
  45363. CLEARCOAT: boolean;
  45364. CLEARCOAT_DEFAULTIOR: boolean;
  45365. CLEARCOAT_TEXTURE: boolean;
  45366. CLEARCOAT_TEXTUREDIRECTUV: number;
  45367. CLEARCOAT_BUMP: boolean;
  45368. CLEARCOAT_BUMPDIRECTUV: number;
  45369. CLEARCOAT_TINT: boolean;
  45370. CLEARCOAT_TINT_TEXTURE: boolean;
  45371. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45372. /** @hidden */
  45373. _areTexturesDirty: boolean;
  45374. }
  45375. /**
  45376. * Define the code related to the clear coat parameters of the pbr material.
  45377. */
  45378. export class PBRClearCoatConfiguration {
  45379. /**
  45380. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45381. * The default fits with a polyurethane material.
  45382. */
  45383. private static readonly _DefaultIndexOfRefraction;
  45384. private _isEnabled;
  45385. /**
  45386. * Defines if the clear coat is enabled in the material.
  45387. */
  45388. isEnabled: boolean;
  45389. /**
  45390. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45391. */
  45392. intensity: number;
  45393. /**
  45394. * Defines the clear coat layer roughness.
  45395. */
  45396. roughness: number;
  45397. private _indexOfRefraction;
  45398. /**
  45399. * Defines the index of refraction of the clear coat.
  45400. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45401. * The default fits with a polyurethane material.
  45402. * Changing the default value is more performance intensive.
  45403. */
  45404. indexOfRefraction: number;
  45405. private _texture;
  45406. /**
  45407. * Stores the clear coat values in a texture.
  45408. */
  45409. texture: Nullable<BaseTexture>;
  45410. private _bumpTexture;
  45411. /**
  45412. * Define the clear coat specific bump texture.
  45413. */
  45414. bumpTexture: Nullable<BaseTexture>;
  45415. private _isTintEnabled;
  45416. /**
  45417. * Defines if the clear coat tint is enabled in the material.
  45418. */
  45419. isTintEnabled: boolean;
  45420. /**
  45421. * Defines the clear coat tint of the material.
  45422. * This is only use if tint is enabled
  45423. */
  45424. tintColor: Color3;
  45425. /**
  45426. * Defines the distance at which the tint color should be found in the
  45427. * clear coat media.
  45428. * This is only use if tint is enabled
  45429. */
  45430. tintColorAtDistance: number;
  45431. /**
  45432. * Defines the clear coat layer thickness.
  45433. * This is only use if tint is enabled
  45434. */
  45435. tintThickness: number;
  45436. private _tintTexture;
  45437. /**
  45438. * Stores the clear tint values in a texture.
  45439. * rgb is tint
  45440. * a is a thickness factor
  45441. */
  45442. tintTexture: Nullable<BaseTexture>;
  45443. /** @hidden */
  45444. private _internalMarkAllSubMeshesAsTexturesDirty;
  45445. /** @hidden */
  45446. _markAllSubMeshesAsTexturesDirty(): void;
  45447. /**
  45448. * Instantiate a new istance of clear coat configuration.
  45449. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45450. */
  45451. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45452. /**
  45453. * Gets wehter the submesh is ready to be used or not.
  45454. * @param defines the list of "defines" to update.
  45455. * @param scene defines the scene the material belongs to.
  45456. * @param engine defines the engine the material belongs to.
  45457. * @param disableBumpMap defines wether the material disables bump or not.
  45458. * @returns - boolean indicating that the submesh is ready or not.
  45459. */
  45460. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45461. /**
  45462. * Checks to see if a texture is used in the material.
  45463. * @param defines the list of "defines" to update.
  45464. * @param scene defines the scene to the material belongs to.
  45465. */
  45466. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45467. /**
  45468. * Binds the material data.
  45469. * @param uniformBuffer defines the Uniform buffer to fill in.
  45470. * @param scene defines the scene the material belongs to.
  45471. * @param engine defines the engine the material belongs to.
  45472. * @param disableBumpMap defines wether the material disables bump or not.
  45473. * @param isFrozen defines wether the material is frozen or not.
  45474. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45475. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45476. */
  45477. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45478. /**
  45479. * Checks to see if a texture is used in the material.
  45480. * @param texture - Base texture to use.
  45481. * @returns - Boolean specifying if a texture is used in the material.
  45482. */
  45483. hasTexture(texture: BaseTexture): boolean;
  45484. /**
  45485. * Returns an array of the actively used textures.
  45486. * @param activeTextures Array of BaseTextures
  45487. */
  45488. getActiveTextures(activeTextures: BaseTexture[]): void;
  45489. /**
  45490. * Returns the animatable textures.
  45491. * @param animatables Array of animatable textures.
  45492. */
  45493. getAnimatables(animatables: IAnimatable[]): void;
  45494. /**
  45495. * Disposes the resources of the material.
  45496. * @param forceDisposeTextures - Forces the disposal of all textures.
  45497. */
  45498. dispose(forceDisposeTextures?: boolean): void;
  45499. /**
  45500. * Get the current class name of the texture useful for serialization or dynamic coding.
  45501. * @returns "PBRClearCoatConfiguration"
  45502. */
  45503. getClassName(): string;
  45504. /**
  45505. * Add fallbacks to the effect fallbacks list.
  45506. * @param defines defines the Base texture to use.
  45507. * @param fallbacks defines the current fallback list.
  45508. * @param currentRank defines the current fallback rank.
  45509. * @returns the new fallback rank.
  45510. */
  45511. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45512. /**
  45513. * Add the required uniforms to the current list.
  45514. * @param uniforms defines the current uniform list.
  45515. */
  45516. static AddUniforms(uniforms: string[]): void;
  45517. /**
  45518. * Add the required samplers to the current list.
  45519. * @param samplers defines the current sampler list.
  45520. */
  45521. static AddSamplers(samplers: string[]): void;
  45522. /**
  45523. * Add the required uniforms to the current buffer.
  45524. * @param uniformBuffer defines the current uniform buffer.
  45525. */
  45526. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45527. /**
  45528. * Makes a duplicate of the current configuration into another one.
  45529. * @param clearCoatConfiguration define the config where to copy the info
  45530. */
  45531. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45532. /**
  45533. * Serializes this clear coat configuration.
  45534. * @returns - An object with the serialized config.
  45535. */
  45536. serialize(): any;
  45537. /**
  45538. * Parses a anisotropy Configuration from a serialized object.
  45539. * @param source - Serialized object.
  45540. * @param scene Defines the scene we are parsing for
  45541. * @param rootUrl Defines the rootUrl to load from
  45542. */
  45543. parse(source: any, scene: Scene, rootUrl: string): void;
  45544. }
  45545. }
  45546. declare module BABYLON {
  45547. /**
  45548. * @hidden
  45549. */
  45550. export interface IMaterialAnisotropicDefines {
  45551. ANISOTROPIC: boolean;
  45552. ANISOTROPIC_TEXTURE: boolean;
  45553. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45554. MAINUV1: boolean;
  45555. _areTexturesDirty: boolean;
  45556. _needUVs: boolean;
  45557. }
  45558. /**
  45559. * Define the code related to the anisotropic parameters of the pbr material.
  45560. */
  45561. export class PBRAnisotropicConfiguration {
  45562. private _isEnabled;
  45563. /**
  45564. * Defines if the anisotropy is enabled in the material.
  45565. */
  45566. isEnabled: boolean;
  45567. /**
  45568. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45569. */
  45570. intensity: number;
  45571. /**
  45572. * Defines if the effect is along the tangents, bitangents or in between.
  45573. * By default, the effect is "strectching" the highlights along the tangents.
  45574. */
  45575. direction: Vector2;
  45576. private _texture;
  45577. /**
  45578. * Stores the anisotropy values in a texture.
  45579. * rg is direction (like normal from -1 to 1)
  45580. * b is a intensity
  45581. */
  45582. texture: Nullable<BaseTexture>;
  45583. /** @hidden */
  45584. private _internalMarkAllSubMeshesAsTexturesDirty;
  45585. /** @hidden */
  45586. _markAllSubMeshesAsTexturesDirty(): void;
  45587. /**
  45588. * Instantiate a new istance of anisotropy configuration.
  45589. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45590. */
  45591. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45592. /**
  45593. * Specifies that the submesh is ready to be used.
  45594. * @param defines the list of "defines" to update.
  45595. * @param scene defines the scene the material belongs to.
  45596. * @returns - boolean indicating that the submesh is ready or not.
  45597. */
  45598. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45599. /**
  45600. * Checks to see if a texture is used in the material.
  45601. * @param defines the list of "defines" to update.
  45602. * @param mesh the mesh we are preparing the defines for.
  45603. * @param scene defines the scene the material belongs to.
  45604. */
  45605. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45606. /**
  45607. * Binds the material data.
  45608. * @param uniformBuffer defines the Uniform buffer to fill in.
  45609. * @param scene defines the scene the material belongs to.
  45610. * @param isFrozen defines wether the material is frozen or not.
  45611. */
  45612. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45613. /**
  45614. * Checks to see if a texture is used in the material.
  45615. * @param texture - Base texture to use.
  45616. * @returns - Boolean specifying if a texture is used in the material.
  45617. */
  45618. hasTexture(texture: BaseTexture): boolean;
  45619. /**
  45620. * Returns an array of the actively used textures.
  45621. * @param activeTextures Array of BaseTextures
  45622. */
  45623. getActiveTextures(activeTextures: BaseTexture[]): void;
  45624. /**
  45625. * Returns the animatable textures.
  45626. * @param animatables Array of animatable textures.
  45627. */
  45628. getAnimatables(animatables: IAnimatable[]): void;
  45629. /**
  45630. * Disposes the resources of the material.
  45631. * @param forceDisposeTextures - Forces the disposal of all textures.
  45632. */
  45633. dispose(forceDisposeTextures?: boolean): void;
  45634. /**
  45635. * Get the current class name of the texture useful for serialization or dynamic coding.
  45636. * @returns "PBRAnisotropicConfiguration"
  45637. */
  45638. getClassName(): string;
  45639. /**
  45640. * Add fallbacks to the effect fallbacks list.
  45641. * @param defines defines the Base texture to use.
  45642. * @param fallbacks defines the current fallback list.
  45643. * @param currentRank defines the current fallback rank.
  45644. * @returns the new fallback rank.
  45645. */
  45646. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45647. /**
  45648. * Add the required uniforms to the current list.
  45649. * @param uniforms defines the current uniform list.
  45650. */
  45651. static AddUniforms(uniforms: string[]): void;
  45652. /**
  45653. * Add the required uniforms to the current buffer.
  45654. * @param uniformBuffer defines the current uniform buffer.
  45655. */
  45656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45657. /**
  45658. * Add the required samplers to the current list.
  45659. * @param samplers defines the current sampler list.
  45660. */
  45661. static AddSamplers(samplers: string[]): void;
  45662. /**
  45663. * Makes a duplicate of the current configuration into another one.
  45664. * @param anisotropicConfiguration define the config where to copy the info
  45665. */
  45666. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45667. /**
  45668. * Serializes this anisotropy configuration.
  45669. * @returns - An object with the serialized config.
  45670. */
  45671. serialize(): any;
  45672. /**
  45673. * Parses a anisotropy Configuration from a serialized object.
  45674. * @param source - Serialized object.
  45675. * @param scene Defines the scene we are parsing for
  45676. * @param rootUrl Defines the rootUrl to load from
  45677. */
  45678. parse(source: any, scene: Scene, rootUrl: string): void;
  45679. }
  45680. }
  45681. declare module BABYLON {
  45682. /**
  45683. * @hidden
  45684. */
  45685. export interface IMaterialBRDFDefines {
  45686. BRDF_V_HEIGHT_CORRELATED: boolean;
  45687. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45688. SPHERICAL_HARMONICS: boolean;
  45689. /** @hidden */
  45690. _areMiscDirty: boolean;
  45691. }
  45692. /**
  45693. * Define the code related to the BRDF parameters of the pbr material.
  45694. */
  45695. export class PBRBRDFConfiguration {
  45696. /**
  45697. * Default value used for the energy conservation.
  45698. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45699. */
  45700. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45701. /**
  45702. * Default value used for the Smith Visibility Height Correlated mode.
  45703. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45704. */
  45705. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45706. /**
  45707. * Default value used for the IBL diffuse part.
  45708. * This can help switching back to the polynomials mode globally which is a tiny bit
  45709. * less GPU intensive at the drawback of a lower quality.
  45710. */
  45711. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45712. private _useEnergyConservation;
  45713. /**
  45714. * Defines if the material uses energy conservation.
  45715. */
  45716. useEnergyConservation: boolean;
  45717. private _useSmithVisibilityHeightCorrelated;
  45718. /**
  45719. * LEGACY Mode set to false
  45720. * Defines if the material uses height smith correlated visibility term.
  45721. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45722. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45723. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45724. * Not relying on height correlated will also disable energy conservation.
  45725. */
  45726. useSmithVisibilityHeightCorrelated: boolean;
  45727. private _useSphericalHarmonics;
  45728. /**
  45729. * LEGACY Mode set to false
  45730. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45731. * diffuse part of the IBL.
  45732. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45733. * to the ground truth.
  45734. */
  45735. useSphericalHarmonics: boolean;
  45736. /** @hidden */
  45737. private _internalMarkAllSubMeshesAsMiscDirty;
  45738. /** @hidden */
  45739. _markAllSubMeshesAsMiscDirty(): void;
  45740. /**
  45741. * Instantiate a new istance of clear coat configuration.
  45742. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45743. */
  45744. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45745. /**
  45746. * Checks to see if a texture is used in the material.
  45747. * @param defines the list of "defines" to update.
  45748. */
  45749. prepareDefines(defines: IMaterialBRDFDefines): void;
  45750. /**
  45751. * Get the current class name of the texture useful for serialization or dynamic coding.
  45752. * @returns "PBRClearCoatConfiguration"
  45753. */
  45754. getClassName(): string;
  45755. /**
  45756. * Makes a duplicate of the current configuration into another one.
  45757. * @param brdfConfiguration define the config where to copy the info
  45758. */
  45759. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45760. /**
  45761. * Serializes this BRDF configuration.
  45762. * @returns - An object with the serialized config.
  45763. */
  45764. serialize(): any;
  45765. /**
  45766. * Parses a anisotropy Configuration from a serialized object.
  45767. * @param source - Serialized object.
  45768. * @param scene Defines the scene we are parsing for
  45769. * @param rootUrl Defines the rootUrl to load from
  45770. */
  45771. parse(source: any, scene: Scene, rootUrl: string): void;
  45772. }
  45773. }
  45774. declare module BABYLON {
  45775. /**
  45776. * @hidden
  45777. */
  45778. export interface IMaterialSheenDefines {
  45779. SHEEN: boolean;
  45780. SHEEN_TEXTURE: boolean;
  45781. SHEEN_TEXTUREDIRECTUV: number;
  45782. SHEEN_LINKWITHALBEDO: boolean;
  45783. /** @hidden */
  45784. _areTexturesDirty: boolean;
  45785. }
  45786. /**
  45787. * Define the code related to the Sheen parameters of the pbr material.
  45788. */
  45789. export class PBRSheenConfiguration {
  45790. private _isEnabled;
  45791. /**
  45792. * Defines if the material uses sheen.
  45793. */
  45794. isEnabled: boolean;
  45795. private _linkSheenWithAlbedo;
  45796. /**
  45797. * Defines if the sheen is linked to the sheen color.
  45798. */
  45799. linkSheenWithAlbedo: boolean;
  45800. /**
  45801. * Defines the sheen intensity.
  45802. */
  45803. intensity: number;
  45804. /**
  45805. * Defines the sheen color.
  45806. */
  45807. color: Color3;
  45808. private _texture;
  45809. /**
  45810. * Stores the sheen tint values in a texture.
  45811. * rgb is tint
  45812. * a is a intensity
  45813. */
  45814. texture: Nullable<BaseTexture>;
  45815. /** @hidden */
  45816. private _internalMarkAllSubMeshesAsTexturesDirty;
  45817. /** @hidden */
  45818. _markAllSubMeshesAsTexturesDirty(): void;
  45819. /**
  45820. * Instantiate a new istance of clear coat configuration.
  45821. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45822. */
  45823. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45824. /**
  45825. * Specifies that the submesh is ready to be used.
  45826. * @param defines the list of "defines" to update.
  45827. * @param scene defines the scene the material belongs to.
  45828. * @returns - boolean indicating that the submesh is ready or not.
  45829. */
  45830. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45831. /**
  45832. * Checks to see if a texture is used in the material.
  45833. * @param defines the list of "defines" to update.
  45834. * @param scene defines the scene the material belongs to.
  45835. */
  45836. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45837. /**
  45838. * Binds the material data.
  45839. * @param uniformBuffer defines the Uniform buffer to fill in.
  45840. * @param scene defines the scene the material belongs to.
  45841. * @param isFrozen defines wether the material is frozen or not.
  45842. */
  45843. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45844. /**
  45845. * Checks to see if a texture is used in the material.
  45846. * @param texture - Base texture to use.
  45847. * @returns - Boolean specifying if a texture is used in the material.
  45848. */
  45849. hasTexture(texture: BaseTexture): boolean;
  45850. /**
  45851. * Returns an array of the actively used textures.
  45852. * @param activeTextures Array of BaseTextures
  45853. */
  45854. getActiveTextures(activeTextures: BaseTexture[]): void;
  45855. /**
  45856. * Returns the animatable textures.
  45857. * @param animatables Array of animatable textures.
  45858. */
  45859. getAnimatables(animatables: IAnimatable[]): void;
  45860. /**
  45861. * Disposes the resources of the material.
  45862. * @param forceDisposeTextures - Forces the disposal of all textures.
  45863. */
  45864. dispose(forceDisposeTextures?: boolean): void;
  45865. /**
  45866. * Get the current class name of the texture useful for serialization or dynamic coding.
  45867. * @returns "PBRSheenConfiguration"
  45868. */
  45869. getClassName(): string;
  45870. /**
  45871. * Add fallbacks to the effect fallbacks list.
  45872. * @param defines defines the Base texture to use.
  45873. * @param fallbacks defines the current fallback list.
  45874. * @param currentRank defines the current fallback rank.
  45875. * @returns the new fallback rank.
  45876. */
  45877. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45878. /**
  45879. * Add the required uniforms to the current list.
  45880. * @param uniforms defines the current uniform list.
  45881. */
  45882. static AddUniforms(uniforms: string[]): void;
  45883. /**
  45884. * Add the required uniforms to the current buffer.
  45885. * @param uniformBuffer defines the current uniform buffer.
  45886. */
  45887. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45888. /**
  45889. * Add the required samplers to the current list.
  45890. * @param samplers defines the current sampler list.
  45891. */
  45892. static AddSamplers(samplers: string[]): void;
  45893. /**
  45894. * Makes a duplicate of the current configuration into another one.
  45895. * @param sheenConfiguration define the config where to copy the info
  45896. */
  45897. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45898. /**
  45899. * Serializes this BRDF configuration.
  45900. * @returns - An object with the serialized config.
  45901. */
  45902. serialize(): any;
  45903. /**
  45904. * Parses a anisotropy Configuration from a serialized object.
  45905. * @param source - Serialized object.
  45906. * @param scene Defines the scene we are parsing for
  45907. * @param rootUrl Defines the rootUrl to load from
  45908. */
  45909. parse(source: any, scene: Scene, rootUrl: string): void;
  45910. }
  45911. }
  45912. declare module BABYLON {
  45913. /**
  45914. * @hidden
  45915. */
  45916. export interface IMaterialSubSurfaceDefines {
  45917. SUBSURFACE: boolean;
  45918. SS_REFRACTION: boolean;
  45919. SS_TRANSLUCENCY: boolean;
  45920. SS_SCATERRING: boolean;
  45921. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45922. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45923. SS_REFRACTIONMAP_3D: boolean;
  45924. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45925. SS_LODINREFRACTIONALPHA: boolean;
  45926. SS_GAMMAREFRACTION: boolean;
  45927. SS_RGBDREFRACTION: boolean;
  45928. SS_LINEARSPECULARREFRACTION: boolean;
  45929. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45930. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45931. /** @hidden */
  45932. _areTexturesDirty: boolean;
  45933. }
  45934. /**
  45935. * Define the code related to the sub surface parameters of the pbr material.
  45936. */
  45937. export class PBRSubSurfaceConfiguration {
  45938. private _isRefractionEnabled;
  45939. /**
  45940. * Defines if the refraction is enabled in the material.
  45941. */
  45942. isRefractionEnabled: boolean;
  45943. private _isTranslucencyEnabled;
  45944. /**
  45945. * Defines if the translucency is enabled in the material.
  45946. */
  45947. isTranslucencyEnabled: boolean;
  45948. private _isScatteringEnabled;
  45949. /**
  45950. * Defines the refraction intensity of the material.
  45951. * The refraction when enabled replaces the Diffuse part of the material.
  45952. * The intensity helps transitionning between diffuse and refraction.
  45953. */
  45954. refractionIntensity: number;
  45955. /**
  45956. * Defines the translucency intensity of the material.
  45957. * When translucency has been enabled, this defines how much of the "translucency"
  45958. * is addded to the diffuse part of the material.
  45959. */
  45960. translucencyIntensity: number;
  45961. /**
  45962. * Defines the scattering intensity of the material.
  45963. * When scattering has been enabled, this defines how much of the "scattered light"
  45964. * is addded to the diffuse part of the material.
  45965. */
  45966. scatteringIntensity: number;
  45967. private _thicknessTexture;
  45968. /**
  45969. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45970. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45971. * 0 would mean minimumThickness
  45972. * 1 would mean maximumThickness
  45973. * The other channels might be use as a mask to vary the different effects intensity.
  45974. */
  45975. thicknessTexture: Nullable<BaseTexture>;
  45976. private _refractionTexture;
  45977. /**
  45978. * Defines the texture to use for refraction.
  45979. */
  45980. refractionTexture: Nullable<BaseTexture>;
  45981. private _indexOfRefraction;
  45982. /**
  45983. * Defines the index of refraction used in the material.
  45984. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45985. */
  45986. indexOfRefraction: number;
  45987. private _invertRefractionY;
  45988. /**
  45989. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45990. */
  45991. invertRefractionY: boolean;
  45992. private _linkRefractionWithTransparency;
  45993. /**
  45994. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45995. * Materials half opaque for instance using refraction could benefit from this control.
  45996. */
  45997. linkRefractionWithTransparency: boolean;
  45998. /**
  45999. * Defines the minimum thickness stored in the thickness map.
  46000. * If no thickness map is defined, this value will be used to simulate thickness.
  46001. */
  46002. minimumThickness: number;
  46003. /**
  46004. * Defines the maximum thickness stored in the thickness map.
  46005. */
  46006. maximumThickness: number;
  46007. /**
  46008. * Defines the volume tint of the material.
  46009. * This is used for both translucency and scattering.
  46010. */
  46011. tintColor: Color3;
  46012. /**
  46013. * Defines the distance at which the tint color should be found in the media.
  46014. * This is used for refraction only.
  46015. */
  46016. tintColorAtDistance: number;
  46017. /**
  46018. * Defines how far each channel transmit through the media.
  46019. * It is defined as a color to simplify it selection.
  46020. */
  46021. diffusionDistance: Color3;
  46022. private _useMaskFromThicknessTexture;
  46023. /**
  46024. * Stores the intensity of the different subsurface effects in the thickness texture.
  46025. * * the green channel is the translucency intensity.
  46026. * * the blue channel is the scattering intensity.
  46027. * * the alpha channel is the refraction intensity.
  46028. */
  46029. useMaskFromThicknessTexture: boolean;
  46030. /** @hidden */
  46031. private _internalMarkAllSubMeshesAsTexturesDirty;
  46032. /** @hidden */
  46033. _markAllSubMeshesAsTexturesDirty(): void;
  46034. /**
  46035. * Instantiate a new istance of sub surface configuration.
  46036. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46037. */
  46038. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46039. /**
  46040. * Gets wehter the submesh is ready to be used or not.
  46041. * @param defines the list of "defines" to update.
  46042. * @param scene defines the scene the material belongs to.
  46043. * @returns - boolean indicating that the submesh is ready or not.
  46044. */
  46045. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46046. /**
  46047. * Checks to see if a texture is used in the material.
  46048. * @param defines the list of "defines" to update.
  46049. * @param scene defines the scene to the material belongs to.
  46050. */
  46051. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46052. /**
  46053. * Binds the material data.
  46054. * @param uniformBuffer defines the Uniform buffer to fill in.
  46055. * @param scene defines the scene the material belongs to.
  46056. * @param engine defines the engine the material belongs to.
  46057. * @param isFrozen defines wether the material is frozen or not.
  46058. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46059. */
  46060. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46061. /**
  46062. * Unbinds the material from the mesh.
  46063. * @param activeEffect defines the effect that should be unbound from.
  46064. * @returns true if unbound, otherwise false
  46065. */
  46066. unbind(activeEffect: Effect): boolean;
  46067. /**
  46068. * Returns the texture used for refraction or null if none is used.
  46069. * @param scene defines the scene the material belongs to.
  46070. * @returns - Refraction texture if present. If no refraction texture and refraction
  46071. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46072. */
  46073. private _getRefractionTexture;
  46074. /**
  46075. * Returns true if alpha blending should be disabled.
  46076. */
  46077. readonly disableAlphaBlending: boolean;
  46078. /**
  46079. * Fills the list of render target textures.
  46080. * @param renderTargets the list of render targets to update
  46081. */
  46082. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46083. /**
  46084. * Checks to see if a texture is used in the material.
  46085. * @param texture - Base texture to use.
  46086. * @returns - Boolean specifying if a texture is used in the material.
  46087. */
  46088. hasTexture(texture: BaseTexture): boolean;
  46089. /**
  46090. * Gets a boolean indicating that current material needs to register RTT
  46091. * @returns true if this uses a render target otherwise false.
  46092. */
  46093. hasRenderTargetTextures(): boolean;
  46094. /**
  46095. * Returns an array of the actively used textures.
  46096. * @param activeTextures Array of BaseTextures
  46097. */
  46098. getActiveTextures(activeTextures: BaseTexture[]): void;
  46099. /**
  46100. * Returns the animatable textures.
  46101. * @param animatables Array of animatable textures.
  46102. */
  46103. getAnimatables(animatables: IAnimatable[]): void;
  46104. /**
  46105. * Disposes the resources of the material.
  46106. * @param forceDisposeTextures - Forces the disposal of all textures.
  46107. */
  46108. dispose(forceDisposeTextures?: boolean): void;
  46109. /**
  46110. * Get the current class name of the texture useful for serialization or dynamic coding.
  46111. * @returns "PBRSubSurfaceConfiguration"
  46112. */
  46113. getClassName(): string;
  46114. /**
  46115. * Add fallbacks to the effect fallbacks list.
  46116. * @param defines defines the Base texture to use.
  46117. * @param fallbacks defines the current fallback list.
  46118. * @param currentRank defines the current fallback rank.
  46119. * @returns the new fallback rank.
  46120. */
  46121. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46122. /**
  46123. * Add the required uniforms to the current list.
  46124. * @param uniforms defines the current uniform list.
  46125. */
  46126. static AddUniforms(uniforms: string[]): void;
  46127. /**
  46128. * Add the required samplers to the current list.
  46129. * @param samplers defines the current sampler list.
  46130. */
  46131. static AddSamplers(samplers: string[]): void;
  46132. /**
  46133. * Add the required uniforms to the current buffer.
  46134. * @param uniformBuffer defines the current uniform buffer.
  46135. */
  46136. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46137. /**
  46138. * Makes a duplicate of the current configuration into another one.
  46139. * @param configuration define the config where to copy the info
  46140. */
  46141. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46142. /**
  46143. * Serializes this Sub Surface configuration.
  46144. * @returns - An object with the serialized config.
  46145. */
  46146. serialize(): any;
  46147. /**
  46148. * Parses a anisotropy Configuration from a serialized object.
  46149. * @param source - Serialized object.
  46150. * @param scene Defines the scene we are parsing for
  46151. * @param rootUrl Defines the rootUrl to load from
  46152. */
  46153. parse(source: any, scene: Scene, rootUrl: string): void;
  46154. }
  46155. }
  46156. declare module BABYLON {
  46157. /** @hidden */
  46158. export var pbrFragmentDeclaration: {
  46159. name: string;
  46160. shader: string;
  46161. };
  46162. }
  46163. declare module BABYLON {
  46164. /** @hidden */
  46165. export var pbrUboDeclaration: {
  46166. name: string;
  46167. shader: string;
  46168. };
  46169. }
  46170. declare module BABYLON {
  46171. /** @hidden */
  46172. export var pbrFragmentExtraDeclaration: {
  46173. name: string;
  46174. shader: string;
  46175. };
  46176. }
  46177. declare module BABYLON {
  46178. /** @hidden */
  46179. export var pbrFragmentSamplersDeclaration: {
  46180. name: string;
  46181. shader: string;
  46182. };
  46183. }
  46184. declare module BABYLON {
  46185. /** @hidden */
  46186. export var pbrHelperFunctions: {
  46187. name: string;
  46188. shader: string;
  46189. };
  46190. }
  46191. declare module BABYLON {
  46192. /** @hidden */
  46193. export var harmonicsFunctions: {
  46194. name: string;
  46195. shader: string;
  46196. };
  46197. }
  46198. declare module BABYLON {
  46199. /** @hidden */
  46200. export var pbrDirectLightingSetupFunctions: {
  46201. name: string;
  46202. shader: string;
  46203. };
  46204. }
  46205. declare module BABYLON {
  46206. /** @hidden */
  46207. export var pbrDirectLightingFalloffFunctions: {
  46208. name: string;
  46209. shader: string;
  46210. };
  46211. }
  46212. declare module BABYLON {
  46213. /** @hidden */
  46214. export var pbrBRDFFunctions: {
  46215. name: string;
  46216. shader: string;
  46217. };
  46218. }
  46219. declare module BABYLON {
  46220. /** @hidden */
  46221. export var pbrDirectLightingFunctions: {
  46222. name: string;
  46223. shader: string;
  46224. };
  46225. }
  46226. declare module BABYLON {
  46227. /** @hidden */
  46228. export var pbrIBLFunctions: {
  46229. name: string;
  46230. shader: string;
  46231. };
  46232. }
  46233. declare module BABYLON {
  46234. /** @hidden */
  46235. export var pbrDebug: {
  46236. name: string;
  46237. shader: string;
  46238. };
  46239. }
  46240. declare module BABYLON {
  46241. /** @hidden */
  46242. export var pbrPixelShader: {
  46243. name: string;
  46244. shader: string;
  46245. };
  46246. }
  46247. declare module BABYLON {
  46248. /** @hidden */
  46249. export var pbrVertexDeclaration: {
  46250. name: string;
  46251. shader: string;
  46252. };
  46253. }
  46254. declare module BABYLON {
  46255. /** @hidden */
  46256. export var pbrVertexShader: {
  46257. name: string;
  46258. shader: string;
  46259. };
  46260. }
  46261. declare module BABYLON {
  46262. /**
  46263. * Manages the defines for the PBR Material.
  46264. * @hidden
  46265. */
  46266. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46267. PBR: boolean;
  46268. MAINUV1: boolean;
  46269. MAINUV2: boolean;
  46270. UV1: boolean;
  46271. UV2: boolean;
  46272. ALBEDO: boolean;
  46273. ALBEDODIRECTUV: number;
  46274. VERTEXCOLOR: boolean;
  46275. AMBIENT: boolean;
  46276. AMBIENTDIRECTUV: number;
  46277. AMBIENTINGRAYSCALE: boolean;
  46278. OPACITY: boolean;
  46279. VERTEXALPHA: boolean;
  46280. OPACITYDIRECTUV: number;
  46281. OPACITYRGB: boolean;
  46282. ALPHATEST: boolean;
  46283. DEPTHPREPASS: boolean;
  46284. ALPHABLEND: boolean;
  46285. ALPHAFROMALBEDO: boolean;
  46286. ALPHATESTVALUE: string;
  46287. SPECULAROVERALPHA: boolean;
  46288. RADIANCEOVERALPHA: boolean;
  46289. ALPHAFRESNEL: boolean;
  46290. LINEARALPHAFRESNEL: boolean;
  46291. PREMULTIPLYALPHA: boolean;
  46292. EMISSIVE: boolean;
  46293. EMISSIVEDIRECTUV: number;
  46294. REFLECTIVITY: boolean;
  46295. REFLECTIVITYDIRECTUV: number;
  46296. SPECULARTERM: boolean;
  46297. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46298. MICROSURFACEAUTOMATIC: boolean;
  46299. LODBASEDMICROSFURACE: boolean;
  46300. MICROSURFACEMAP: boolean;
  46301. MICROSURFACEMAPDIRECTUV: number;
  46302. METALLICWORKFLOW: boolean;
  46303. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46304. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46305. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46306. AOSTOREINMETALMAPRED: boolean;
  46307. ENVIRONMENTBRDF: boolean;
  46308. ENVIRONMENTBRDF_RGBD: boolean;
  46309. NORMAL: boolean;
  46310. TANGENT: boolean;
  46311. BUMP: boolean;
  46312. BUMPDIRECTUV: number;
  46313. OBJECTSPACE_NORMALMAP: boolean;
  46314. PARALLAX: boolean;
  46315. PARALLAXOCCLUSION: boolean;
  46316. NORMALXYSCALE: boolean;
  46317. LIGHTMAP: boolean;
  46318. LIGHTMAPDIRECTUV: number;
  46319. USELIGHTMAPASSHADOWMAP: boolean;
  46320. GAMMALIGHTMAP: boolean;
  46321. REFLECTION: boolean;
  46322. REFLECTIONMAP_3D: boolean;
  46323. REFLECTIONMAP_SPHERICAL: boolean;
  46324. REFLECTIONMAP_PLANAR: boolean;
  46325. REFLECTIONMAP_CUBIC: boolean;
  46326. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46327. REFLECTIONMAP_PROJECTION: boolean;
  46328. REFLECTIONMAP_SKYBOX: boolean;
  46329. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46330. REFLECTIONMAP_EXPLICIT: boolean;
  46331. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46332. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46333. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46334. INVERTCUBICMAP: boolean;
  46335. USESPHERICALFROMREFLECTIONMAP: boolean;
  46336. USEIRRADIANCEMAP: boolean;
  46337. SPHERICAL_HARMONICS: boolean;
  46338. USESPHERICALINVERTEX: boolean;
  46339. REFLECTIONMAP_OPPOSITEZ: boolean;
  46340. LODINREFLECTIONALPHA: boolean;
  46341. GAMMAREFLECTION: boolean;
  46342. RGBDREFLECTION: boolean;
  46343. LINEARSPECULARREFLECTION: boolean;
  46344. RADIANCEOCCLUSION: boolean;
  46345. HORIZONOCCLUSION: boolean;
  46346. INSTANCES: boolean;
  46347. NUM_BONE_INFLUENCERS: number;
  46348. BonesPerMesh: number;
  46349. BONETEXTURE: boolean;
  46350. NONUNIFORMSCALING: boolean;
  46351. MORPHTARGETS: boolean;
  46352. MORPHTARGETS_NORMAL: boolean;
  46353. MORPHTARGETS_TANGENT: boolean;
  46354. MORPHTARGETS_UV: boolean;
  46355. NUM_MORPH_INFLUENCERS: number;
  46356. IMAGEPROCESSING: boolean;
  46357. VIGNETTE: boolean;
  46358. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46359. VIGNETTEBLENDMODEOPAQUE: boolean;
  46360. TONEMAPPING: boolean;
  46361. TONEMAPPING_ACES: boolean;
  46362. CONTRAST: boolean;
  46363. COLORCURVES: boolean;
  46364. COLORGRADING: boolean;
  46365. COLORGRADING3D: boolean;
  46366. SAMPLER3DGREENDEPTH: boolean;
  46367. SAMPLER3DBGRMAP: boolean;
  46368. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46369. EXPOSURE: boolean;
  46370. MULTIVIEW: boolean;
  46371. USEPHYSICALLIGHTFALLOFF: boolean;
  46372. USEGLTFLIGHTFALLOFF: boolean;
  46373. TWOSIDEDLIGHTING: boolean;
  46374. SHADOWFLOAT: boolean;
  46375. CLIPPLANE: boolean;
  46376. CLIPPLANE2: boolean;
  46377. CLIPPLANE3: boolean;
  46378. CLIPPLANE4: boolean;
  46379. POINTSIZE: boolean;
  46380. FOG: boolean;
  46381. LOGARITHMICDEPTH: boolean;
  46382. FORCENORMALFORWARD: boolean;
  46383. SPECULARAA: boolean;
  46384. CLEARCOAT: boolean;
  46385. CLEARCOAT_DEFAULTIOR: boolean;
  46386. CLEARCOAT_TEXTURE: boolean;
  46387. CLEARCOAT_TEXTUREDIRECTUV: number;
  46388. CLEARCOAT_BUMP: boolean;
  46389. CLEARCOAT_BUMPDIRECTUV: number;
  46390. CLEARCOAT_TINT: boolean;
  46391. CLEARCOAT_TINT_TEXTURE: boolean;
  46392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46393. ANISOTROPIC: boolean;
  46394. ANISOTROPIC_TEXTURE: boolean;
  46395. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46396. BRDF_V_HEIGHT_CORRELATED: boolean;
  46397. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46398. SHEEN: boolean;
  46399. SHEEN_TEXTURE: boolean;
  46400. SHEEN_TEXTUREDIRECTUV: number;
  46401. SHEEN_LINKWITHALBEDO: boolean;
  46402. SUBSURFACE: boolean;
  46403. SS_REFRACTION: boolean;
  46404. SS_TRANSLUCENCY: boolean;
  46405. SS_SCATERRING: boolean;
  46406. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46407. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46408. SS_REFRACTIONMAP_3D: boolean;
  46409. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46410. SS_LODINREFRACTIONALPHA: boolean;
  46411. SS_GAMMAREFRACTION: boolean;
  46412. SS_RGBDREFRACTION: boolean;
  46413. SS_LINEARSPECULARREFRACTION: boolean;
  46414. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46415. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46416. UNLIT: boolean;
  46417. DEBUGMODE: number;
  46418. /**
  46419. * Initializes the PBR Material defines.
  46420. */
  46421. constructor();
  46422. /**
  46423. * Resets the PBR Material defines.
  46424. */
  46425. reset(): void;
  46426. }
  46427. /**
  46428. * The Physically based material base class of BJS.
  46429. *
  46430. * This offers the main features of a standard PBR material.
  46431. * For more information, please refer to the documentation :
  46432. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46433. */
  46434. export abstract class PBRBaseMaterial extends PushMaterial {
  46435. /**
  46436. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46437. */
  46438. static readonly PBRMATERIAL_OPAQUE: number;
  46439. /**
  46440. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46441. */
  46442. static readonly PBRMATERIAL_ALPHATEST: number;
  46443. /**
  46444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46445. */
  46446. static readonly PBRMATERIAL_ALPHABLEND: number;
  46447. /**
  46448. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46449. * They are also discarded below the alpha cutoff threshold to improve performances.
  46450. */
  46451. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46452. /**
  46453. * Defines the default value of how much AO map is occluding the analytical lights
  46454. * (point spot...).
  46455. */
  46456. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46457. /**
  46458. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46459. */
  46460. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46461. /**
  46462. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46463. * to enhance interoperability with other engines.
  46464. */
  46465. static readonly LIGHTFALLOFF_GLTF: number;
  46466. /**
  46467. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46468. * to enhance interoperability with other materials.
  46469. */
  46470. static readonly LIGHTFALLOFF_STANDARD: number;
  46471. /**
  46472. * Intensity of the direct lights e.g. the four lights available in your scene.
  46473. * This impacts both the direct diffuse and specular highlights.
  46474. */
  46475. protected _directIntensity: number;
  46476. /**
  46477. * Intensity of the emissive part of the material.
  46478. * This helps controlling the emissive effect without modifying the emissive color.
  46479. */
  46480. protected _emissiveIntensity: number;
  46481. /**
  46482. * Intensity of the environment e.g. how much the environment will light the object
  46483. * either through harmonics for rough material or through the refelction for shiny ones.
  46484. */
  46485. protected _environmentIntensity: number;
  46486. /**
  46487. * This is a special control allowing the reduction of the specular highlights coming from the
  46488. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46489. */
  46490. protected _specularIntensity: number;
  46491. /**
  46492. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46493. */
  46494. private _lightingInfos;
  46495. /**
  46496. * Debug Control allowing disabling the bump map on this material.
  46497. */
  46498. protected _disableBumpMap: boolean;
  46499. /**
  46500. * AKA Diffuse Texture in standard nomenclature.
  46501. */
  46502. protected _albedoTexture: Nullable<BaseTexture>;
  46503. /**
  46504. * AKA Occlusion Texture in other nomenclature.
  46505. */
  46506. protected _ambientTexture: Nullable<BaseTexture>;
  46507. /**
  46508. * AKA Occlusion Texture Intensity in other nomenclature.
  46509. */
  46510. protected _ambientTextureStrength: number;
  46511. /**
  46512. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46513. * 1 means it completely occludes it
  46514. * 0 mean it has no impact
  46515. */
  46516. protected _ambientTextureImpactOnAnalyticalLights: number;
  46517. /**
  46518. * Stores the alpha values in a texture.
  46519. */
  46520. protected _opacityTexture: Nullable<BaseTexture>;
  46521. /**
  46522. * Stores the reflection values in a texture.
  46523. */
  46524. protected _reflectionTexture: Nullable<BaseTexture>;
  46525. /**
  46526. * Stores the emissive values in a texture.
  46527. */
  46528. protected _emissiveTexture: Nullable<BaseTexture>;
  46529. /**
  46530. * AKA Specular texture in other nomenclature.
  46531. */
  46532. protected _reflectivityTexture: Nullable<BaseTexture>;
  46533. /**
  46534. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46535. */
  46536. protected _metallicTexture: Nullable<BaseTexture>;
  46537. /**
  46538. * Specifies the metallic scalar of the metallic/roughness workflow.
  46539. * Can also be used to scale the metalness values of the metallic texture.
  46540. */
  46541. protected _metallic: Nullable<number>;
  46542. /**
  46543. * Specifies the roughness scalar of the metallic/roughness workflow.
  46544. * Can also be used to scale the roughness values of the metallic texture.
  46545. */
  46546. protected _roughness: Nullable<number>;
  46547. /**
  46548. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46549. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46550. */
  46551. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46552. /**
  46553. * Stores surface normal data used to displace a mesh in a texture.
  46554. */
  46555. protected _bumpTexture: Nullable<BaseTexture>;
  46556. /**
  46557. * Stores the pre-calculated light information of a mesh in a texture.
  46558. */
  46559. protected _lightmapTexture: Nullable<BaseTexture>;
  46560. /**
  46561. * The color of a material in ambient lighting.
  46562. */
  46563. protected _ambientColor: Color3;
  46564. /**
  46565. * AKA Diffuse Color in other nomenclature.
  46566. */
  46567. protected _albedoColor: Color3;
  46568. /**
  46569. * AKA Specular Color in other nomenclature.
  46570. */
  46571. protected _reflectivityColor: Color3;
  46572. /**
  46573. * The color applied when light is reflected from a material.
  46574. */
  46575. protected _reflectionColor: Color3;
  46576. /**
  46577. * The color applied when light is emitted from a material.
  46578. */
  46579. protected _emissiveColor: Color3;
  46580. /**
  46581. * AKA Glossiness in other nomenclature.
  46582. */
  46583. protected _microSurface: number;
  46584. /**
  46585. * Specifies that the material will use the light map as a show map.
  46586. */
  46587. protected _useLightmapAsShadowmap: boolean;
  46588. /**
  46589. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46590. * makes the reflect vector face the model (under horizon).
  46591. */
  46592. protected _useHorizonOcclusion: boolean;
  46593. /**
  46594. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46595. * too much the area relying on ambient texture to define their ambient occlusion.
  46596. */
  46597. protected _useRadianceOcclusion: boolean;
  46598. /**
  46599. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46600. */
  46601. protected _useAlphaFromAlbedoTexture: boolean;
  46602. /**
  46603. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46604. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46605. */
  46606. protected _useSpecularOverAlpha: boolean;
  46607. /**
  46608. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46609. */
  46610. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46611. /**
  46612. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46613. */
  46614. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46615. /**
  46616. * Specifies if the metallic texture contains the roughness information in its green channel.
  46617. */
  46618. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46619. /**
  46620. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46621. */
  46622. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46623. /**
  46624. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46625. */
  46626. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46627. /**
  46628. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46629. */
  46630. protected _useAmbientInGrayScale: boolean;
  46631. /**
  46632. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46633. * The material will try to infer what glossiness each pixel should be.
  46634. */
  46635. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46636. /**
  46637. * Defines the falloff type used in this material.
  46638. * It by default is Physical.
  46639. */
  46640. protected _lightFalloff: number;
  46641. /**
  46642. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46643. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46644. */
  46645. protected _useRadianceOverAlpha: boolean;
  46646. /**
  46647. * Allows using an object space normal map (instead of tangent space).
  46648. */
  46649. protected _useObjectSpaceNormalMap: boolean;
  46650. /**
  46651. * Allows using the bump map in parallax mode.
  46652. */
  46653. protected _useParallax: boolean;
  46654. /**
  46655. * Allows using the bump map in parallax occlusion mode.
  46656. */
  46657. protected _useParallaxOcclusion: boolean;
  46658. /**
  46659. * Controls the scale bias of the parallax mode.
  46660. */
  46661. protected _parallaxScaleBias: number;
  46662. /**
  46663. * If sets to true, disables all the lights affecting the material.
  46664. */
  46665. protected _disableLighting: boolean;
  46666. /**
  46667. * Number of Simultaneous lights allowed on the material.
  46668. */
  46669. protected _maxSimultaneousLights: number;
  46670. /**
  46671. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46672. */
  46673. protected _invertNormalMapX: boolean;
  46674. /**
  46675. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46676. */
  46677. protected _invertNormalMapY: boolean;
  46678. /**
  46679. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46680. */
  46681. protected _twoSidedLighting: boolean;
  46682. /**
  46683. * Defines the alpha limits in alpha test mode.
  46684. */
  46685. protected _alphaCutOff: number;
  46686. /**
  46687. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46688. */
  46689. protected _forceAlphaTest: boolean;
  46690. /**
  46691. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46692. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46693. */
  46694. protected _useAlphaFresnel: boolean;
  46695. /**
  46696. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46697. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46698. */
  46699. protected _useLinearAlphaFresnel: boolean;
  46700. /**
  46701. * The transparency mode of the material.
  46702. */
  46703. protected _transparencyMode: Nullable<number>;
  46704. /**
  46705. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46706. * from cos thetav and roughness:
  46707. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46708. */
  46709. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46710. /**
  46711. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46712. */
  46713. protected _forceIrradianceInFragment: boolean;
  46714. /**
  46715. * Force normal to face away from face.
  46716. */
  46717. protected _forceNormalForward: boolean;
  46718. /**
  46719. * Enables specular anti aliasing in the PBR shader.
  46720. * It will both interacts on the Geometry for analytical and IBL lighting.
  46721. * It also prefilter the roughness map based on the bump values.
  46722. */
  46723. protected _enableSpecularAntiAliasing: boolean;
  46724. /**
  46725. * Default configuration related to image processing available in the PBR Material.
  46726. */
  46727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46728. /**
  46729. * Keep track of the image processing observer to allow dispose and replace.
  46730. */
  46731. private _imageProcessingObserver;
  46732. /**
  46733. * Attaches a new image processing configuration to the PBR Material.
  46734. * @param configuration
  46735. */
  46736. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46737. /**
  46738. * Stores the available render targets.
  46739. */
  46740. private _renderTargets;
  46741. /**
  46742. * Sets the global ambient color for the material used in lighting calculations.
  46743. */
  46744. private _globalAmbientColor;
  46745. /**
  46746. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46747. */
  46748. private _useLogarithmicDepth;
  46749. /**
  46750. * If set to true, no lighting calculations will be applied.
  46751. */
  46752. private _unlit;
  46753. private _debugMode;
  46754. /**
  46755. * @hidden
  46756. * This is reserved for the inspector.
  46757. * Defines the material debug mode.
  46758. * It helps seeing only some components of the material while troubleshooting.
  46759. */
  46760. debugMode: number;
  46761. /**
  46762. * @hidden
  46763. * This is reserved for the inspector.
  46764. * Specify from where on screen the debug mode should start.
  46765. * The value goes from -1 (full screen) to 1 (not visible)
  46766. * It helps with side by side comparison against the final render
  46767. * This defaults to -1
  46768. */
  46769. private debugLimit;
  46770. /**
  46771. * @hidden
  46772. * This is reserved for the inspector.
  46773. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46774. * You can use the factor to better multiply the final value.
  46775. */
  46776. private debugFactor;
  46777. /**
  46778. * Defines the clear coat layer parameters for the material.
  46779. */
  46780. readonly clearCoat: PBRClearCoatConfiguration;
  46781. /**
  46782. * Defines the anisotropic parameters for the material.
  46783. */
  46784. readonly anisotropy: PBRAnisotropicConfiguration;
  46785. /**
  46786. * Defines the BRDF parameters for the material.
  46787. */
  46788. readonly brdf: PBRBRDFConfiguration;
  46789. /**
  46790. * Defines the Sheen parameters for the material.
  46791. */
  46792. readonly sheen: PBRSheenConfiguration;
  46793. /**
  46794. * Defines the SubSurface parameters for the material.
  46795. */
  46796. readonly subSurface: PBRSubSurfaceConfiguration;
  46797. /**
  46798. * Custom callback helping to override the default shader used in the material.
  46799. */
  46800. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46801. /**
  46802. * Instantiates a new PBRMaterial instance.
  46803. *
  46804. * @param name The material name
  46805. * @param scene The scene the material will be use in.
  46806. */
  46807. constructor(name: string, scene: Scene);
  46808. /**
  46809. * Gets a boolean indicating that current material needs to register RTT
  46810. */
  46811. readonly hasRenderTargetTextures: boolean;
  46812. /**
  46813. * Gets the name of the material class.
  46814. */
  46815. getClassName(): string;
  46816. /**
  46817. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46818. */
  46819. /**
  46820. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46821. */
  46822. useLogarithmicDepth: boolean;
  46823. /**
  46824. * Gets the current transparency mode.
  46825. */
  46826. /**
  46827. * Sets the transparency mode of the material.
  46828. *
  46829. * | Value | Type | Description |
  46830. * | ----- | ----------------------------------- | ----------- |
  46831. * | 0 | OPAQUE | |
  46832. * | 1 | ALPHATEST | |
  46833. * | 2 | ALPHABLEND | |
  46834. * | 3 | ALPHATESTANDBLEND | |
  46835. *
  46836. */
  46837. transparencyMode: Nullable<number>;
  46838. /**
  46839. * Returns true if alpha blending should be disabled.
  46840. */
  46841. private readonly _disableAlphaBlending;
  46842. /**
  46843. * Specifies whether or not this material should be rendered in alpha blend mode.
  46844. */
  46845. needAlphaBlending(): boolean;
  46846. /**
  46847. * Specifies if the mesh will require alpha blending.
  46848. * @param mesh - BJS mesh.
  46849. */
  46850. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46851. /**
  46852. * Specifies whether or not this material should be rendered in alpha test mode.
  46853. */
  46854. needAlphaTesting(): boolean;
  46855. /**
  46856. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46857. */
  46858. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46859. /**
  46860. * Gets the texture used for the alpha test.
  46861. */
  46862. getAlphaTestTexture(): Nullable<BaseTexture>;
  46863. /**
  46864. * Specifies that the submesh is ready to be used.
  46865. * @param mesh - BJS mesh.
  46866. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46867. * @param useInstances - Specifies that instances should be used.
  46868. * @returns - boolean indicating that the submesh is ready or not.
  46869. */
  46870. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46871. /**
  46872. * Specifies if the material uses metallic roughness workflow.
  46873. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46874. */
  46875. isMetallicWorkflow(): boolean;
  46876. private _prepareEffect;
  46877. private _prepareDefines;
  46878. /**
  46879. * Force shader compilation
  46880. */
  46881. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46882. clipPlane: boolean;
  46883. }>): void;
  46884. /**
  46885. * Initializes the uniform buffer layout for the shader.
  46886. */
  46887. buildUniformLayout(): void;
  46888. /**
  46889. * Unbinds the material from the mesh
  46890. */
  46891. unbind(): void;
  46892. /**
  46893. * Binds the submesh data.
  46894. * @param world - The world matrix.
  46895. * @param mesh - The BJS mesh.
  46896. * @param subMesh - A submesh of the BJS mesh.
  46897. */
  46898. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46899. /**
  46900. * Returns the animatable textures.
  46901. * @returns - Array of animatable textures.
  46902. */
  46903. getAnimatables(): IAnimatable[];
  46904. /**
  46905. * Returns the texture used for reflections.
  46906. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46907. */
  46908. private _getReflectionTexture;
  46909. /**
  46910. * Returns an array of the actively used textures.
  46911. * @returns - Array of BaseTextures
  46912. */
  46913. getActiveTextures(): BaseTexture[];
  46914. /**
  46915. * Checks to see if a texture is used in the material.
  46916. * @param texture - Base texture to use.
  46917. * @returns - Boolean specifying if a texture is used in the material.
  46918. */
  46919. hasTexture(texture: BaseTexture): boolean;
  46920. /**
  46921. * Disposes the resources of the material.
  46922. * @param forceDisposeEffect - Forces the disposal of effects.
  46923. * @param forceDisposeTextures - Forces the disposal of all textures.
  46924. */
  46925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46926. }
  46927. }
  46928. declare module BABYLON {
  46929. /**
  46930. * The Physically based material of BJS.
  46931. *
  46932. * This offers the main features of a standard PBR material.
  46933. * For more information, please refer to the documentation :
  46934. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46935. */
  46936. export class PBRMaterial extends PBRBaseMaterial {
  46937. /**
  46938. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46939. */
  46940. static readonly PBRMATERIAL_OPAQUE: number;
  46941. /**
  46942. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46943. */
  46944. static readonly PBRMATERIAL_ALPHATEST: number;
  46945. /**
  46946. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46947. */
  46948. static readonly PBRMATERIAL_ALPHABLEND: number;
  46949. /**
  46950. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46951. * They are also discarded below the alpha cutoff threshold to improve performances.
  46952. */
  46953. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46954. /**
  46955. * Defines the default value of how much AO map is occluding the analytical lights
  46956. * (point spot...).
  46957. */
  46958. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46959. /**
  46960. * Intensity of the direct lights e.g. the four lights available in your scene.
  46961. * This impacts both the direct diffuse and specular highlights.
  46962. */
  46963. directIntensity: number;
  46964. /**
  46965. * Intensity of the emissive part of the material.
  46966. * This helps controlling the emissive effect without modifying the emissive color.
  46967. */
  46968. emissiveIntensity: number;
  46969. /**
  46970. * Intensity of the environment e.g. how much the environment will light the object
  46971. * either through harmonics for rough material or through the refelction for shiny ones.
  46972. */
  46973. environmentIntensity: number;
  46974. /**
  46975. * This is a special control allowing the reduction of the specular highlights coming from the
  46976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46977. */
  46978. specularIntensity: number;
  46979. /**
  46980. * Debug Control allowing disabling the bump map on this material.
  46981. */
  46982. disableBumpMap: boolean;
  46983. /**
  46984. * AKA Diffuse Texture in standard nomenclature.
  46985. */
  46986. albedoTexture: BaseTexture;
  46987. /**
  46988. * AKA Occlusion Texture in other nomenclature.
  46989. */
  46990. ambientTexture: BaseTexture;
  46991. /**
  46992. * AKA Occlusion Texture Intensity in other nomenclature.
  46993. */
  46994. ambientTextureStrength: number;
  46995. /**
  46996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46997. * 1 means it completely occludes it
  46998. * 0 mean it has no impact
  46999. */
  47000. ambientTextureImpactOnAnalyticalLights: number;
  47001. /**
  47002. * Stores the alpha values in a texture.
  47003. */
  47004. opacityTexture: BaseTexture;
  47005. /**
  47006. * Stores the reflection values in a texture.
  47007. */
  47008. reflectionTexture: Nullable<BaseTexture>;
  47009. /**
  47010. * Stores the emissive values in a texture.
  47011. */
  47012. emissiveTexture: BaseTexture;
  47013. /**
  47014. * AKA Specular texture in other nomenclature.
  47015. */
  47016. reflectivityTexture: BaseTexture;
  47017. /**
  47018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47019. */
  47020. metallicTexture: BaseTexture;
  47021. /**
  47022. * Specifies the metallic scalar of the metallic/roughness workflow.
  47023. * Can also be used to scale the metalness values of the metallic texture.
  47024. */
  47025. metallic: Nullable<number>;
  47026. /**
  47027. * Specifies the roughness scalar of the metallic/roughness workflow.
  47028. * Can also be used to scale the roughness values of the metallic texture.
  47029. */
  47030. roughness: Nullable<number>;
  47031. /**
  47032. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47033. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47034. */
  47035. microSurfaceTexture: BaseTexture;
  47036. /**
  47037. * Stores surface normal data used to displace a mesh in a texture.
  47038. */
  47039. bumpTexture: BaseTexture;
  47040. /**
  47041. * Stores the pre-calculated light information of a mesh in a texture.
  47042. */
  47043. lightmapTexture: BaseTexture;
  47044. /**
  47045. * Stores the refracted light information in a texture.
  47046. */
  47047. refractionTexture: Nullable<BaseTexture>;
  47048. /**
  47049. * The color of a material in ambient lighting.
  47050. */
  47051. ambientColor: Color3;
  47052. /**
  47053. * AKA Diffuse Color in other nomenclature.
  47054. */
  47055. albedoColor: Color3;
  47056. /**
  47057. * AKA Specular Color in other nomenclature.
  47058. */
  47059. reflectivityColor: Color3;
  47060. /**
  47061. * The color reflected from the material.
  47062. */
  47063. reflectionColor: Color3;
  47064. /**
  47065. * The color emitted from the material.
  47066. */
  47067. emissiveColor: Color3;
  47068. /**
  47069. * AKA Glossiness in other nomenclature.
  47070. */
  47071. microSurface: number;
  47072. /**
  47073. * source material index of refraction (IOR)' / 'destination material IOR.
  47074. */
  47075. indexOfRefraction: number;
  47076. /**
  47077. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47078. */
  47079. invertRefractionY: boolean;
  47080. /**
  47081. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47082. * Materials half opaque for instance using refraction could benefit from this control.
  47083. */
  47084. linkRefractionWithTransparency: boolean;
  47085. /**
  47086. * If true, the light map contains occlusion information instead of lighting info.
  47087. */
  47088. useLightmapAsShadowmap: boolean;
  47089. /**
  47090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47091. */
  47092. useAlphaFromAlbedoTexture: boolean;
  47093. /**
  47094. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47095. */
  47096. forceAlphaTest: boolean;
  47097. /**
  47098. * Defines the alpha limits in alpha test mode.
  47099. */
  47100. alphaCutOff: number;
  47101. /**
  47102. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47103. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47104. */
  47105. useSpecularOverAlpha: boolean;
  47106. /**
  47107. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47108. */
  47109. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47110. /**
  47111. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47112. */
  47113. useRoughnessFromMetallicTextureAlpha: boolean;
  47114. /**
  47115. * Specifies if the metallic texture contains the roughness information in its green channel.
  47116. */
  47117. useRoughnessFromMetallicTextureGreen: boolean;
  47118. /**
  47119. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47120. */
  47121. useMetallnessFromMetallicTextureBlue: boolean;
  47122. /**
  47123. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47124. */
  47125. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47126. /**
  47127. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47128. */
  47129. useAmbientInGrayScale: boolean;
  47130. /**
  47131. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47132. * The material will try to infer what glossiness each pixel should be.
  47133. */
  47134. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47135. /**
  47136. * BJS is using an harcoded light falloff based on a manually sets up range.
  47137. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47138. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47139. */
  47140. /**
  47141. * BJS is using an harcoded light falloff based on a manually sets up range.
  47142. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47143. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47144. */
  47145. usePhysicalLightFalloff: boolean;
  47146. /**
  47147. * In order to support the falloff compatibility with gltf, a special mode has been added
  47148. * to reproduce the gltf light falloff.
  47149. */
  47150. /**
  47151. * In order to support the falloff compatibility with gltf, a special mode has been added
  47152. * to reproduce the gltf light falloff.
  47153. */
  47154. useGLTFLightFalloff: boolean;
  47155. /**
  47156. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47157. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47158. */
  47159. useRadianceOverAlpha: boolean;
  47160. /**
  47161. * Allows using an object space normal map (instead of tangent space).
  47162. */
  47163. useObjectSpaceNormalMap: boolean;
  47164. /**
  47165. * Allows using the bump map in parallax mode.
  47166. */
  47167. useParallax: boolean;
  47168. /**
  47169. * Allows using the bump map in parallax occlusion mode.
  47170. */
  47171. useParallaxOcclusion: boolean;
  47172. /**
  47173. * Controls the scale bias of the parallax mode.
  47174. */
  47175. parallaxScaleBias: number;
  47176. /**
  47177. * If sets to true, disables all the lights affecting the material.
  47178. */
  47179. disableLighting: boolean;
  47180. /**
  47181. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47182. */
  47183. forceIrradianceInFragment: boolean;
  47184. /**
  47185. * Number of Simultaneous lights allowed on the material.
  47186. */
  47187. maxSimultaneousLights: number;
  47188. /**
  47189. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47190. */
  47191. invertNormalMapX: boolean;
  47192. /**
  47193. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47194. */
  47195. invertNormalMapY: boolean;
  47196. /**
  47197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47198. */
  47199. twoSidedLighting: boolean;
  47200. /**
  47201. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47202. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47203. */
  47204. useAlphaFresnel: boolean;
  47205. /**
  47206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47207. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47208. */
  47209. useLinearAlphaFresnel: boolean;
  47210. /**
  47211. * Let user defines the brdf lookup texture used for IBL.
  47212. * A default 8bit version is embedded but you could point at :
  47213. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47214. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47215. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47216. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47217. */
  47218. environmentBRDFTexture: Nullable<BaseTexture>;
  47219. /**
  47220. * Force normal to face away from face.
  47221. */
  47222. forceNormalForward: boolean;
  47223. /**
  47224. * Enables specular anti aliasing in the PBR shader.
  47225. * It will both interacts on the Geometry for analytical and IBL lighting.
  47226. * It also prefilter the roughness map based on the bump values.
  47227. */
  47228. enableSpecularAntiAliasing: boolean;
  47229. /**
  47230. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47231. * makes the reflect vector face the model (under horizon).
  47232. */
  47233. useHorizonOcclusion: boolean;
  47234. /**
  47235. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47236. * too much the area relying on ambient texture to define their ambient occlusion.
  47237. */
  47238. useRadianceOcclusion: boolean;
  47239. /**
  47240. * If set to true, no lighting calculations will be applied.
  47241. */
  47242. unlit: boolean;
  47243. /**
  47244. * Gets the image processing configuration used either in this material.
  47245. */
  47246. /**
  47247. * Sets the Default image processing configuration used either in the this material.
  47248. *
  47249. * If sets to null, the scene one is in use.
  47250. */
  47251. imageProcessingConfiguration: ImageProcessingConfiguration;
  47252. /**
  47253. * Gets wether the color curves effect is enabled.
  47254. */
  47255. /**
  47256. * Sets wether the color curves effect is enabled.
  47257. */
  47258. cameraColorCurvesEnabled: boolean;
  47259. /**
  47260. * Gets wether the color grading effect is enabled.
  47261. */
  47262. /**
  47263. * Gets wether the color grading effect is enabled.
  47264. */
  47265. cameraColorGradingEnabled: boolean;
  47266. /**
  47267. * Gets wether tonemapping is enabled or not.
  47268. */
  47269. /**
  47270. * Sets wether tonemapping is enabled or not
  47271. */
  47272. cameraToneMappingEnabled: boolean;
  47273. /**
  47274. * The camera exposure used on this material.
  47275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47276. * This corresponds to a photographic exposure.
  47277. */
  47278. /**
  47279. * The camera exposure used on this material.
  47280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47281. * This corresponds to a photographic exposure.
  47282. */
  47283. cameraExposure: number;
  47284. /**
  47285. * Gets The camera contrast used on this material.
  47286. */
  47287. /**
  47288. * Sets The camera contrast used on this material.
  47289. */
  47290. cameraContrast: number;
  47291. /**
  47292. * Gets the Color Grading 2D Lookup Texture.
  47293. */
  47294. /**
  47295. * Sets the Color Grading 2D Lookup Texture.
  47296. */
  47297. cameraColorGradingTexture: Nullable<BaseTexture>;
  47298. /**
  47299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47301. * 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;
  47302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47303. */
  47304. /**
  47305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47307. * 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;
  47308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47309. */
  47310. cameraColorCurves: Nullable<ColorCurves>;
  47311. /**
  47312. * Instantiates a new PBRMaterial instance.
  47313. *
  47314. * @param name The material name
  47315. * @param scene The scene the material will be use in.
  47316. */
  47317. constructor(name: string, scene: Scene);
  47318. /**
  47319. * Returns the name of this material class.
  47320. */
  47321. getClassName(): string;
  47322. /**
  47323. * Makes a duplicate of the current material.
  47324. * @param name - name to use for the new material.
  47325. */
  47326. clone(name: string): PBRMaterial;
  47327. /**
  47328. * Serializes this PBR Material.
  47329. * @returns - An object with the serialized material.
  47330. */
  47331. serialize(): any;
  47332. /**
  47333. * Parses a PBR Material from a serialized object.
  47334. * @param source - Serialized object.
  47335. * @param scene - BJS scene instance.
  47336. * @param rootUrl - url for the scene object
  47337. * @returns - PBRMaterial
  47338. */
  47339. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47340. }
  47341. }
  47342. declare module BABYLON {
  47343. /**
  47344. * Direct draw surface info
  47345. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47346. */
  47347. export interface DDSInfo {
  47348. /**
  47349. * Width of the texture
  47350. */
  47351. width: number;
  47352. /**
  47353. * Width of the texture
  47354. */
  47355. height: number;
  47356. /**
  47357. * Number of Mipmaps for the texture
  47358. * @see https://en.wikipedia.org/wiki/Mipmap
  47359. */
  47360. mipmapCount: number;
  47361. /**
  47362. * If the textures format is a known fourCC format
  47363. * @see https://www.fourcc.org/
  47364. */
  47365. isFourCC: boolean;
  47366. /**
  47367. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47368. */
  47369. isRGB: boolean;
  47370. /**
  47371. * If the texture is a lumincance format
  47372. */
  47373. isLuminance: boolean;
  47374. /**
  47375. * If this is a cube texture
  47376. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47377. */
  47378. isCube: boolean;
  47379. /**
  47380. * If the texture is a compressed format eg. FOURCC_DXT1
  47381. */
  47382. isCompressed: boolean;
  47383. /**
  47384. * The dxgiFormat of the texture
  47385. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47386. */
  47387. dxgiFormat: number;
  47388. /**
  47389. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47390. */
  47391. textureType: number;
  47392. /**
  47393. * Sphericle polynomial created for the dds texture
  47394. */
  47395. sphericalPolynomial?: SphericalPolynomial;
  47396. }
  47397. /**
  47398. * Class used to provide DDS decompression tools
  47399. */
  47400. export class DDSTools {
  47401. /**
  47402. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47403. */
  47404. static StoreLODInAlphaChannel: boolean;
  47405. /**
  47406. * Gets DDS information from an array buffer
  47407. * @param arrayBuffer defines the array buffer to read data from
  47408. * @returns the DDS information
  47409. */
  47410. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47411. private static _FloatView;
  47412. private static _Int32View;
  47413. private static _ToHalfFloat;
  47414. private static _FromHalfFloat;
  47415. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47416. private static _GetHalfFloatRGBAArrayBuffer;
  47417. private static _GetFloatRGBAArrayBuffer;
  47418. private static _GetFloatAsUIntRGBAArrayBuffer;
  47419. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47420. private static _GetRGBAArrayBuffer;
  47421. private static _ExtractLongWordOrder;
  47422. private static _GetRGBArrayBuffer;
  47423. private static _GetLuminanceArrayBuffer;
  47424. /**
  47425. * Uploads DDS Levels to a Babylon Texture
  47426. * @hidden
  47427. */
  47428. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47429. }
  47430. interface Engine {
  47431. /**
  47432. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47433. * @param rootUrl defines the url where the file to load is located
  47434. * @param scene defines the current scene
  47435. * @param lodScale defines scale to apply to the mip map selection
  47436. * @param lodOffset defines offset to apply to the mip map selection
  47437. * @param onLoad defines an optional callback raised when the texture is loaded
  47438. * @param onError defines an optional callback raised if there is an issue to load the texture
  47439. * @param format defines the format of the data
  47440. * @param forcedExtension defines the extension to use to pick the right loader
  47441. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47442. * @returns the cube texture as an InternalTexture
  47443. */
  47444. 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;
  47445. }
  47446. }
  47447. declare module BABYLON {
  47448. /**
  47449. * Implementation of the DDS Texture Loader.
  47450. * @hidden
  47451. */
  47452. export class _DDSTextureLoader implements IInternalTextureLoader {
  47453. /**
  47454. * Defines wether the loader supports cascade loading the different faces.
  47455. */
  47456. readonly supportCascades: boolean;
  47457. /**
  47458. * This returns if the loader support the current file information.
  47459. * @param extension defines the file extension of the file being loaded
  47460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47461. * @param fallback defines the fallback internal texture if any
  47462. * @param isBase64 defines whether the texture is encoded as a base64
  47463. * @param isBuffer defines whether the texture data are stored as a buffer
  47464. * @returns true if the loader can load the specified file
  47465. */
  47466. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47467. /**
  47468. * Transform the url before loading if required.
  47469. * @param rootUrl the url of the texture
  47470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47471. * @returns the transformed texture
  47472. */
  47473. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47474. /**
  47475. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47476. * @param rootUrl the url of the texture
  47477. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47478. * @returns the fallback texture
  47479. */
  47480. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47481. /**
  47482. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47483. * @param data contains the texture data
  47484. * @param texture defines the BabylonJS internal texture
  47485. * @param createPolynomials will be true if polynomials have been requested
  47486. * @param onLoad defines the callback to trigger once the texture is ready
  47487. * @param onError defines the callback to trigger in case of error
  47488. */
  47489. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47490. /**
  47491. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47492. * @param data contains the texture data
  47493. * @param texture defines the BabylonJS internal texture
  47494. * @param callback defines the method to call once ready to upload
  47495. */
  47496. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47497. }
  47498. }
  47499. declare module BABYLON {
  47500. /** @hidden */
  47501. export var rgbdEncodePixelShader: {
  47502. name: string;
  47503. shader: string;
  47504. };
  47505. }
  47506. declare module BABYLON {
  47507. /**
  47508. * Raw texture data and descriptor sufficient for WebGL texture upload
  47509. */
  47510. export interface EnvironmentTextureInfo {
  47511. /**
  47512. * Version of the environment map
  47513. */
  47514. version: number;
  47515. /**
  47516. * Width of image
  47517. */
  47518. width: number;
  47519. /**
  47520. * Irradiance information stored in the file.
  47521. */
  47522. irradiance: any;
  47523. /**
  47524. * Specular information stored in the file.
  47525. */
  47526. specular: any;
  47527. }
  47528. /**
  47529. * Sets of helpers addressing the serialization and deserialization of environment texture
  47530. * stored in a BabylonJS env file.
  47531. * Those files are usually stored as .env files.
  47532. */
  47533. export class EnvironmentTextureTools {
  47534. /**
  47535. * Magic number identifying the env file.
  47536. */
  47537. private static _MagicBytes;
  47538. /**
  47539. * Gets the environment info from an env file.
  47540. * @param data The array buffer containing the .env bytes.
  47541. * @returns the environment file info (the json header) if successfully parsed.
  47542. */
  47543. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47544. /**
  47545. * Creates an environment texture from a loaded cube texture.
  47546. * @param texture defines the cube texture to convert in env file
  47547. * @return a promise containing the environment data if succesfull.
  47548. */
  47549. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47550. /**
  47551. * Creates a JSON representation of the spherical data.
  47552. * @param texture defines the texture containing the polynomials
  47553. * @return the JSON representation of the spherical info
  47554. */
  47555. private static _CreateEnvTextureIrradiance;
  47556. /**
  47557. * Uploads the texture info contained in the env file to the GPU.
  47558. * @param texture defines the internal texture to upload to
  47559. * @param arrayBuffer defines the buffer cotaining the data to load
  47560. * @param info defines the texture info retrieved through the GetEnvInfo method
  47561. * @returns a promise
  47562. */
  47563. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47564. /**
  47565. * Uploads the levels of image data to the GPU.
  47566. * @param texture defines the internal texture to upload to
  47567. * @param imageData defines the array buffer views of image data [mipmap][face]
  47568. * @returns a promise
  47569. */
  47570. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47571. /**
  47572. * Uploads spherical polynomials information to the texture.
  47573. * @param texture defines the texture we are trying to upload the information to
  47574. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47575. */
  47576. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47577. /** @hidden */
  47578. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47579. }
  47580. }
  47581. declare module BABYLON {
  47582. /**
  47583. * Implementation of the ENV Texture Loader.
  47584. * @hidden
  47585. */
  47586. export class _ENVTextureLoader implements IInternalTextureLoader {
  47587. /**
  47588. * Defines wether the loader supports cascade loading the different faces.
  47589. */
  47590. readonly supportCascades: boolean;
  47591. /**
  47592. * This returns if the loader support the current file information.
  47593. * @param extension defines the file extension of the file being loaded
  47594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47595. * @param fallback defines the fallback internal texture if any
  47596. * @param isBase64 defines whether the texture is encoded as a base64
  47597. * @param isBuffer defines whether the texture data are stored as a buffer
  47598. * @returns true if the loader can load the specified file
  47599. */
  47600. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47601. /**
  47602. * Transform the url before loading if required.
  47603. * @param rootUrl the url of the texture
  47604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47605. * @returns the transformed texture
  47606. */
  47607. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47608. /**
  47609. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47610. * @param rootUrl the url of the texture
  47611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47612. * @returns the fallback texture
  47613. */
  47614. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47615. /**
  47616. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47617. * @param data contains the texture data
  47618. * @param texture defines the BabylonJS internal texture
  47619. * @param createPolynomials will be true if polynomials have been requested
  47620. * @param onLoad defines the callback to trigger once the texture is ready
  47621. * @param onError defines the callback to trigger in case of error
  47622. */
  47623. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47624. /**
  47625. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47626. * @param data contains the texture data
  47627. * @param texture defines the BabylonJS internal texture
  47628. * @param callback defines the method to call once ready to upload
  47629. */
  47630. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47631. }
  47632. }
  47633. declare module BABYLON {
  47634. /**
  47635. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47636. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47637. */
  47638. export class KhronosTextureContainer {
  47639. /** contents of the KTX container file */
  47640. arrayBuffer: any;
  47641. private static HEADER_LEN;
  47642. private static COMPRESSED_2D;
  47643. private static COMPRESSED_3D;
  47644. private static TEX_2D;
  47645. private static TEX_3D;
  47646. /**
  47647. * Gets the openGL type
  47648. */
  47649. glType: number;
  47650. /**
  47651. * Gets the openGL type size
  47652. */
  47653. glTypeSize: number;
  47654. /**
  47655. * Gets the openGL format
  47656. */
  47657. glFormat: number;
  47658. /**
  47659. * Gets the openGL internal format
  47660. */
  47661. glInternalFormat: number;
  47662. /**
  47663. * Gets the base internal format
  47664. */
  47665. glBaseInternalFormat: number;
  47666. /**
  47667. * Gets image width in pixel
  47668. */
  47669. pixelWidth: number;
  47670. /**
  47671. * Gets image height in pixel
  47672. */
  47673. pixelHeight: number;
  47674. /**
  47675. * Gets image depth in pixels
  47676. */
  47677. pixelDepth: number;
  47678. /**
  47679. * Gets the number of array elements
  47680. */
  47681. numberOfArrayElements: number;
  47682. /**
  47683. * Gets the number of faces
  47684. */
  47685. numberOfFaces: number;
  47686. /**
  47687. * Gets the number of mipmap levels
  47688. */
  47689. numberOfMipmapLevels: number;
  47690. /**
  47691. * Gets the bytes of key value data
  47692. */
  47693. bytesOfKeyValueData: number;
  47694. /**
  47695. * Gets the load type
  47696. */
  47697. loadType: number;
  47698. /**
  47699. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47700. */
  47701. isInvalid: boolean;
  47702. /**
  47703. * Creates a new KhronosTextureContainer
  47704. * @param arrayBuffer contents of the KTX container file
  47705. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47706. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47707. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47708. */
  47709. constructor(
  47710. /** contents of the KTX container file */
  47711. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47712. /**
  47713. * Uploads KTX content to a Babylon Texture.
  47714. * It is assumed that the texture has already been created & is currently bound
  47715. * @hidden
  47716. */
  47717. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47718. private _upload2DCompressedLevels;
  47719. }
  47720. }
  47721. declare module BABYLON {
  47722. /**
  47723. * Implementation of the KTX Texture Loader.
  47724. * @hidden
  47725. */
  47726. export class _KTXTextureLoader implements IInternalTextureLoader {
  47727. /**
  47728. * Defines wether the loader supports cascade loading the different faces.
  47729. */
  47730. readonly supportCascades: boolean;
  47731. /**
  47732. * This returns if the loader support the current file information.
  47733. * @param extension defines the file extension of the file being loaded
  47734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47735. * @param fallback defines the fallback internal texture if any
  47736. * @param isBase64 defines whether the texture is encoded as a base64
  47737. * @param isBuffer defines whether the texture data are stored as a buffer
  47738. * @returns true if the loader can load the specified file
  47739. */
  47740. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47741. /**
  47742. * Transform the url before loading if required.
  47743. * @param rootUrl the url of the texture
  47744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47745. * @returns the transformed texture
  47746. */
  47747. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47748. /**
  47749. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47750. * @param rootUrl the url of the texture
  47751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47752. * @returns the fallback texture
  47753. */
  47754. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47755. /**
  47756. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47757. * @param data contains the texture data
  47758. * @param texture defines the BabylonJS internal texture
  47759. * @param createPolynomials will be true if polynomials have been requested
  47760. * @param onLoad defines the callback to trigger once the texture is ready
  47761. * @param onError defines the callback to trigger in case of error
  47762. */
  47763. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47764. /**
  47765. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47766. * @param data contains the texture data
  47767. * @param texture defines the BabylonJS internal texture
  47768. * @param callback defines the method to call once ready to upload
  47769. */
  47770. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47771. }
  47772. }
  47773. declare module BABYLON {
  47774. /**
  47775. * Options for the default xr helper
  47776. */
  47777. export class WebXRDefaultExperienceOptions {
  47778. /**
  47779. * Floor meshes that should be used for teleporting
  47780. */
  47781. floorMeshes: Array<AbstractMesh>;
  47782. }
  47783. /**
  47784. * Default experience which provides a similar setup to the previous webVRExperience
  47785. */
  47786. export class WebXRDefaultExperience {
  47787. /**
  47788. * Base experience
  47789. */
  47790. baseExperience: WebXRExperienceHelper;
  47791. /**
  47792. * Input experience extension
  47793. */
  47794. input: WebXRInput;
  47795. /**
  47796. * Loads the controller models
  47797. */
  47798. controllerModelLoader: WebXRControllerModelLoader;
  47799. /**
  47800. * Enables laser pointer and selection
  47801. */
  47802. pointerSelection: WebXRControllerPointerSelection;
  47803. /**
  47804. * Enables teleportation
  47805. */
  47806. teleportation: WebXRControllerTeleportation;
  47807. /**
  47808. * Enables ui for enetering/exiting xr
  47809. */
  47810. enterExitUI: WebXREnterExitUI;
  47811. /**
  47812. * Default output canvas xr should render to
  47813. */
  47814. outputCanvas: WebXRManagedOutputCanvas;
  47815. /**
  47816. * Creates the default xr experience
  47817. * @param scene scene
  47818. * @param options options for basic configuration
  47819. * @returns resulting WebXRDefaultExperience
  47820. */
  47821. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47822. private constructor();
  47823. /**
  47824. * DIsposes of the experience helper
  47825. */
  47826. dispose(): void;
  47827. }
  47828. }
  47829. declare module BABYLON {
  47830. /** @hidden */
  47831. export var _forceSceneHelpersToBundle: boolean;
  47832. interface Scene {
  47833. /**
  47834. * Creates a default light for the scene.
  47835. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47836. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47837. */
  47838. createDefaultLight(replace?: boolean): void;
  47839. /**
  47840. * Creates a default camera for the scene.
  47841. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47842. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47843. * @param replace has default false, when true replaces the active camera in the scene
  47844. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47845. */
  47846. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47847. /**
  47848. * Creates a default camera and a default light.
  47849. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47850. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47851. * @param replace has the default false, when true replaces the active camera/light in the scene
  47852. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47853. */
  47854. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47855. /**
  47856. * Creates a new sky box
  47857. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47858. * @param environmentTexture defines the texture to use as environment texture
  47859. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47860. * @param scale defines the overall scale of the skybox
  47861. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47862. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47863. * @returns a new mesh holding the sky box
  47864. */
  47865. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47866. /**
  47867. * Creates a new environment
  47868. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47869. * @param options defines the options you can use to configure the environment
  47870. * @returns the new EnvironmentHelper
  47871. */
  47872. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47873. /**
  47874. * Creates a new VREXperienceHelper
  47875. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47876. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47877. * @returns a new VREXperienceHelper
  47878. */
  47879. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47880. /**
  47881. * Creates a new WebXRDefaultExperience
  47882. * @see http://doc.babylonjs.com/how_to/webxr
  47883. * @param options experience options
  47884. * @returns a promise for a new WebXRDefaultExperience
  47885. */
  47886. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47887. }
  47888. }
  47889. declare module BABYLON {
  47890. /**
  47891. * Contains position and normal vectors for a vertex
  47892. */
  47893. export class PositionNormalVertex {
  47894. /** the position of the vertex (defaut: 0,0,0) */
  47895. position: Vector3;
  47896. /** the normal of the vertex (defaut: 0,1,0) */
  47897. normal: Vector3;
  47898. /**
  47899. * Creates a PositionNormalVertex
  47900. * @param position the position of the vertex (defaut: 0,0,0)
  47901. * @param normal the normal of the vertex (defaut: 0,1,0)
  47902. */
  47903. constructor(
  47904. /** the position of the vertex (defaut: 0,0,0) */
  47905. position?: Vector3,
  47906. /** the normal of the vertex (defaut: 0,1,0) */
  47907. normal?: Vector3);
  47908. /**
  47909. * Clones the PositionNormalVertex
  47910. * @returns the cloned PositionNormalVertex
  47911. */
  47912. clone(): PositionNormalVertex;
  47913. }
  47914. /**
  47915. * Contains position, normal and uv vectors for a vertex
  47916. */
  47917. export class PositionNormalTextureVertex {
  47918. /** the position of the vertex (defaut: 0,0,0) */
  47919. position: Vector3;
  47920. /** the normal of the vertex (defaut: 0,1,0) */
  47921. normal: Vector3;
  47922. /** the uv of the vertex (default: 0,0) */
  47923. uv: Vector2;
  47924. /**
  47925. * Creates a PositionNormalTextureVertex
  47926. * @param position the position of the vertex (defaut: 0,0,0)
  47927. * @param normal the normal of the vertex (defaut: 0,1,0)
  47928. * @param uv the uv of the vertex (default: 0,0)
  47929. */
  47930. constructor(
  47931. /** the position of the vertex (defaut: 0,0,0) */
  47932. position?: Vector3,
  47933. /** the normal of the vertex (defaut: 0,1,0) */
  47934. normal?: Vector3,
  47935. /** the uv of the vertex (default: 0,0) */
  47936. uv?: Vector2);
  47937. /**
  47938. * Clones the PositionNormalTextureVertex
  47939. * @returns the cloned PositionNormalTextureVertex
  47940. */
  47941. clone(): PositionNormalTextureVertex;
  47942. }
  47943. }
  47944. declare module BABYLON {
  47945. /**
  47946. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47947. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47948. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47949. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47950. */
  47951. export class VideoDome extends TransformNode {
  47952. /**
  47953. * Define the video source as a Monoscopic panoramic 360 video.
  47954. */
  47955. static readonly MODE_MONOSCOPIC: number;
  47956. /**
  47957. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47958. */
  47959. static readonly MODE_TOPBOTTOM: number;
  47960. /**
  47961. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47962. */
  47963. static readonly MODE_SIDEBYSIDE: number;
  47964. private _halfDome;
  47965. private _useDirectMapping;
  47966. /**
  47967. * The video texture being displayed on the sphere
  47968. */
  47969. protected _videoTexture: VideoTexture;
  47970. /**
  47971. * Gets the video texture being displayed on the sphere
  47972. */
  47973. readonly videoTexture: VideoTexture;
  47974. /**
  47975. * The skybox material
  47976. */
  47977. protected _material: BackgroundMaterial;
  47978. /**
  47979. * The surface used for the skybox
  47980. */
  47981. protected _mesh: Mesh;
  47982. /**
  47983. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47984. */
  47985. private _halfDomeMask;
  47986. /**
  47987. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47988. * Also see the options.resolution property.
  47989. */
  47990. fovMultiplier: number;
  47991. private _videoMode;
  47992. /**
  47993. * Gets or set the current video mode for the video. It can be:
  47994. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47995. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47996. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47997. */
  47998. videoMode: number;
  47999. /**
  48000. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48001. *
  48002. */
  48003. /**
  48004. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48005. */
  48006. halfDome: boolean;
  48007. /**
  48008. * Oberserver used in Stereoscopic VR Mode.
  48009. */
  48010. private _onBeforeCameraRenderObserver;
  48011. /**
  48012. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48013. * @param name Element's name, child elements will append suffixes for their own names.
  48014. * @param urlsOrVideo defines the url(s) or the video element to use
  48015. * @param options An object containing optional or exposed sub element properties
  48016. */
  48017. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48018. resolution?: number;
  48019. clickToPlay?: boolean;
  48020. autoPlay?: boolean;
  48021. loop?: boolean;
  48022. size?: number;
  48023. poster?: string;
  48024. faceForward?: boolean;
  48025. useDirectMapping?: boolean;
  48026. halfDomeMode?: boolean;
  48027. }, scene: Scene);
  48028. private _changeVideoMode;
  48029. /**
  48030. * Releases resources associated with this node.
  48031. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48032. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48033. */
  48034. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48035. }
  48036. }
  48037. declare module BABYLON {
  48038. /**
  48039. * This class can be used to get instrumentation data from a Babylon engine
  48040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48041. */
  48042. export class EngineInstrumentation implements IDisposable {
  48043. /**
  48044. * Define the instrumented engine.
  48045. */
  48046. engine: Engine;
  48047. private _captureGPUFrameTime;
  48048. private _gpuFrameTimeToken;
  48049. private _gpuFrameTime;
  48050. private _captureShaderCompilationTime;
  48051. private _shaderCompilationTime;
  48052. private _onBeginFrameObserver;
  48053. private _onEndFrameObserver;
  48054. private _onBeforeShaderCompilationObserver;
  48055. private _onAfterShaderCompilationObserver;
  48056. /**
  48057. * Gets the perf counter used for GPU frame time
  48058. */
  48059. readonly gpuFrameTimeCounter: PerfCounter;
  48060. /**
  48061. * Gets the GPU frame time capture status
  48062. */
  48063. /**
  48064. * Enable or disable the GPU frame time capture
  48065. */
  48066. captureGPUFrameTime: boolean;
  48067. /**
  48068. * Gets the perf counter used for shader compilation time
  48069. */
  48070. readonly shaderCompilationTimeCounter: PerfCounter;
  48071. /**
  48072. * Gets the shader compilation time capture status
  48073. */
  48074. /**
  48075. * Enable or disable the shader compilation time capture
  48076. */
  48077. captureShaderCompilationTime: boolean;
  48078. /**
  48079. * Instantiates a new engine instrumentation.
  48080. * This class can be used to get instrumentation data from a Babylon engine
  48081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48082. * @param engine Defines the engine to instrument
  48083. */
  48084. constructor(
  48085. /**
  48086. * Define the instrumented engine.
  48087. */
  48088. engine: Engine);
  48089. /**
  48090. * Dispose and release associated resources.
  48091. */
  48092. dispose(): void;
  48093. }
  48094. }
  48095. declare module BABYLON {
  48096. /**
  48097. * This class can be used to get instrumentation data from a Babylon engine
  48098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48099. */
  48100. export class SceneInstrumentation implements IDisposable {
  48101. /**
  48102. * Defines the scene to instrument
  48103. */
  48104. scene: Scene;
  48105. private _captureActiveMeshesEvaluationTime;
  48106. private _activeMeshesEvaluationTime;
  48107. private _captureRenderTargetsRenderTime;
  48108. private _renderTargetsRenderTime;
  48109. private _captureFrameTime;
  48110. private _frameTime;
  48111. private _captureRenderTime;
  48112. private _renderTime;
  48113. private _captureInterFrameTime;
  48114. private _interFrameTime;
  48115. private _captureParticlesRenderTime;
  48116. private _particlesRenderTime;
  48117. private _captureSpritesRenderTime;
  48118. private _spritesRenderTime;
  48119. private _capturePhysicsTime;
  48120. private _physicsTime;
  48121. private _captureAnimationsTime;
  48122. private _animationsTime;
  48123. private _captureCameraRenderTime;
  48124. private _cameraRenderTime;
  48125. private _onBeforeActiveMeshesEvaluationObserver;
  48126. private _onAfterActiveMeshesEvaluationObserver;
  48127. private _onBeforeRenderTargetsRenderObserver;
  48128. private _onAfterRenderTargetsRenderObserver;
  48129. private _onAfterRenderObserver;
  48130. private _onBeforeDrawPhaseObserver;
  48131. private _onAfterDrawPhaseObserver;
  48132. private _onBeforeAnimationsObserver;
  48133. private _onBeforeParticlesRenderingObserver;
  48134. private _onAfterParticlesRenderingObserver;
  48135. private _onBeforeSpritesRenderingObserver;
  48136. private _onAfterSpritesRenderingObserver;
  48137. private _onBeforePhysicsObserver;
  48138. private _onAfterPhysicsObserver;
  48139. private _onAfterAnimationsObserver;
  48140. private _onBeforeCameraRenderObserver;
  48141. private _onAfterCameraRenderObserver;
  48142. /**
  48143. * Gets the perf counter used for active meshes evaluation time
  48144. */
  48145. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48146. /**
  48147. * Gets the active meshes evaluation time capture status
  48148. */
  48149. /**
  48150. * Enable or disable the active meshes evaluation time capture
  48151. */
  48152. captureActiveMeshesEvaluationTime: boolean;
  48153. /**
  48154. * Gets the perf counter used for render targets render time
  48155. */
  48156. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48157. /**
  48158. * Gets the render targets render time capture status
  48159. */
  48160. /**
  48161. * Enable or disable the render targets render time capture
  48162. */
  48163. captureRenderTargetsRenderTime: boolean;
  48164. /**
  48165. * Gets the perf counter used for particles render time
  48166. */
  48167. readonly particlesRenderTimeCounter: PerfCounter;
  48168. /**
  48169. * Gets the particles render time capture status
  48170. */
  48171. /**
  48172. * Enable or disable the particles render time capture
  48173. */
  48174. captureParticlesRenderTime: boolean;
  48175. /**
  48176. * Gets the perf counter used for sprites render time
  48177. */
  48178. readonly spritesRenderTimeCounter: PerfCounter;
  48179. /**
  48180. * Gets the sprites render time capture status
  48181. */
  48182. /**
  48183. * Enable or disable the sprites render time capture
  48184. */
  48185. captureSpritesRenderTime: boolean;
  48186. /**
  48187. * Gets the perf counter used for physics time
  48188. */
  48189. readonly physicsTimeCounter: PerfCounter;
  48190. /**
  48191. * Gets the physics time capture status
  48192. */
  48193. /**
  48194. * Enable or disable the physics time capture
  48195. */
  48196. capturePhysicsTime: boolean;
  48197. /**
  48198. * Gets the perf counter used for animations time
  48199. */
  48200. readonly animationsTimeCounter: PerfCounter;
  48201. /**
  48202. * Gets the animations time capture status
  48203. */
  48204. /**
  48205. * Enable or disable the animations time capture
  48206. */
  48207. captureAnimationsTime: boolean;
  48208. /**
  48209. * Gets the perf counter used for frame time capture
  48210. */
  48211. readonly frameTimeCounter: PerfCounter;
  48212. /**
  48213. * Gets the frame time capture status
  48214. */
  48215. /**
  48216. * Enable or disable the frame time capture
  48217. */
  48218. captureFrameTime: boolean;
  48219. /**
  48220. * Gets the perf counter used for inter-frames time capture
  48221. */
  48222. readonly interFrameTimeCounter: PerfCounter;
  48223. /**
  48224. * Gets the inter-frames time capture status
  48225. */
  48226. /**
  48227. * Enable or disable the inter-frames time capture
  48228. */
  48229. captureInterFrameTime: boolean;
  48230. /**
  48231. * Gets the perf counter used for render time capture
  48232. */
  48233. readonly renderTimeCounter: PerfCounter;
  48234. /**
  48235. * Gets the render time capture status
  48236. */
  48237. /**
  48238. * Enable or disable the render time capture
  48239. */
  48240. captureRenderTime: boolean;
  48241. /**
  48242. * Gets the perf counter used for camera render time capture
  48243. */
  48244. readonly cameraRenderTimeCounter: PerfCounter;
  48245. /**
  48246. * Gets the camera render time capture status
  48247. */
  48248. /**
  48249. * Enable or disable the camera render time capture
  48250. */
  48251. captureCameraRenderTime: boolean;
  48252. /**
  48253. * Gets the perf counter used for draw calls
  48254. */
  48255. readonly drawCallsCounter: PerfCounter;
  48256. /**
  48257. * Instantiates a new scene instrumentation.
  48258. * This class can be used to get instrumentation data from a Babylon engine
  48259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48260. * @param scene Defines the scene to instrument
  48261. */
  48262. constructor(
  48263. /**
  48264. * Defines the scene to instrument
  48265. */
  48266. scene: Scene);
  48267. /**
  48268. * Dispose and release associated resources.
  48269. */
  48270. dispose(): void;
  48271. }
  48272. }
  48273. declare module BABYLON {
  48274. /** @hidden */
  48275. export var glowMapGenerationPixelShader: {
  48276. name: string;
  48277. shader: string;
  48278. };
  48279. }
  48280. declare module BABYLON {
  48281. /** @hidden */
  48282. export var glowMapGenerationVertexShader: {
  48283. name: string;
  48284. shader: string;
  48285. };
  48286. }
  48287. declare module BABYLON {
  48288. /**
  48289. * Effect layer options. This helps customizing the behaviour
  48290. * of the effect layer.
  48291. */
  48292. export interface IEffectLayerOptions {
  48293. /**
  48294. * Multiplication factor apply to the canvas size to compute the render target size
  48295. * used to generated the objects (the smaller the faster).
  48296. */
  48297. mainTextureRatio: number;
  48298. /**
  48299. * Enforces a fixed size texture to ensure effect stability across devices.
  48300. */
  48301. mainTextureFixedSize?: number;
  48302. /**
  48303. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48304. */
  48305. alphaBlendingMode: number;
  48306. /**
  48307. * The camera attached to the layer.
  48308. */
  48309. camera: Nullable<Camera>;
  48310. /**
  48311. * The rendering group to draw the layer in.
  48312. */
  48313. renderingGroupId: number;
  48314. }
  48315. /**
  48316. * The effect layer Helps adding post process effect blended with the main pass.
  48317. *
  48318. * This can be for instance use to generate glow or higlight effects on the scene.
  48319. *
  48320. * The effect layer class can not be used directly and is intented to inherited from to be
  48321. * customized per effects.
  48322. */
  48323. export abstract class EffectLayer {
  48324. private _vertexBuffers;
  48325. private _indexBuffer;
  48326. private _cachedDefines;
  48327. private _effectLayerMapGenerationEffect;
  48328. private _effectLayerOptions;
  48329. private _mergeEffect;
  48330. protected _scene: Scene;
  48331. protected _engine: Engine;
  48332. protected _maxSize: number;
  48333. protected _mainTextureDesiredSize: ISize;
  48334. protected _mainTexture: RenderTargetTexture;
  48335. protected _shouldRender: boolean;
  48336. protected _postProcesses: PostProcess[];
  48337. protected _textures: BaseTexture[];
  48338. protected _emissiveTextureAndColor: {
  48339. texture: Nullable<BaseTexture>;
  48340. color: Color4;
  48341. };
  48342. /**
  48343. * The name of the layer
  48344. */
  48345. name: string;
  48346. /**
  48347. * The clear color of the texture used to generate the glow map.
  48348. */
  48349. neutralColor: Color4;
  48350. /**
  48351. * Specifies wether the highlight layer is enabled or not.
  48352. */
  48353. isEnabled: boolean;
  48354. /**
  48355. * Gets the camera attached to the layer.
  48356. */
  48357. readonly camera: Nullable<Camera>;
  48358. /**
  48359. * Gets the rendering group id the layer should render in.
  48360. */
  48361. renderingGroupId: number;
  48362. /**
  48363. * An event triggered when the effect layer has been disposed.
  48364. */
  48365. onDisposeObservable: Observable<EffectLayer>;
  48366. /**
  48367. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48368. */
  48369. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48370. /**
  48371. * An event triggered when the generated texture is being merged in the scene.
  48372. */
  48373. onBeforeComposeObservable: Observable<EffectLayer>;
  48374. /**
  48375. * An event triggered when the generated texture has been merged in the scene.
  48376. */
  48377. onAfterComposeObservable: Observable<EffectLayer>;
  48378. /**
  48379. * An event triggered when the efffect layer changes its size.
  48380. */
  48381. onSizeChangedObservable: Observable<EffectLayer>;
  48382. /** @hidden */
  48383. static _SceneComponentInitialization: (scene: Scene) => void;
  48384. /**
  48385. * Instantiates a new effect Layer and references it in the scene.
  48386. * @param name The name of the layer
  48387. * @param scene The scene to use the layer in
  48388. */
  48389. constructor(
  48390. /** The Friendly of the effect in the scene */
  48391. name: string, scene: Scene);
  48392. /**
  48393. * Get the effect name of the layer.
  48394. * @return The effect name
  48395. */
  48396. abstract getEffectName(): string;
  48397. /**
  48398. * Checks for the readiness of the element composing the layer.
  48399. * @param subMesh the mesh to check for
  48400. * @param useInstances specify wether or not to use instances to render the mesh
  48401. * @return true if ready otherwise, false
  48402. */
  48403. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48404. /**
  48405. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48406. * @returns true if the effect requires stencil during the main canvas render pass.
  48407. */
  48408. abstract needStencil(): boolean;
  48409. /**
  48410. * Create the merge effect. This is the shader use to blit the information back
  48411. * to the main canvas at the end of the scene rendering.
  48412. * @returns The effect containing the shader used to merge the effect on the main canvas
  48413. */
  48414. protected abstract _createMergeEffect(): Effect;
  48415. /**
  48416. * Creates the render target textures and post processes used in the effect layer.
  48417. */
  48418. protected abstract _createTextureAndPostProcesses(): void;
  48419. /**
  48420. * Implementation specific of rendering the generating effect on the main canvas.
  48421. * @param effect The effect used to render through
  48422. */
  48423. protected abstract _internalRender(effect: Effect): void;
  48424. /**
  48425. * Sets the required values for both the emissive texture and and the main color.
  48426. */
  48427. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48428. /**
  48429. * Free any resources and references associated to a mesh.
  48430. * Internal use
  48431. * @param mesh The mesh to free.
  48432. */
  48433. abstract _disposeMesh(mesh: Mesh): void;
  48434. /**
  48435. * Serializes this layer (Glow or Highlight for example)
  48436. * @returns a serialized layer object
  48437. */
  48438. abstract serialize?(): any;
  48439. /**
  48440. * Initializes the effect layer with the required options.
  48441. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48442. */
  48443. protected _init(options: Partial<IEffectLayerOptions>): void;
  48444. /**
  48445. * Generates the index buffer of the full screen quad blending to the main canvas.
  48446. */
  48447. private _generateIndexBuffer;
  48448. /**
  48449. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48450. */
  48451. private _generateVertexBuffer;
  48452. /**
  48453. * Sets the main texture desired size which is the closest power of two
  48454. * of the engine canvas size.
  48455. */
  48456. private _setMainTextureSize;
  48457. /**
  48458. * Creates the main texture for the effect layer.
  48459. */
  48460. protected _createMainTexture(): void;
  48461. /**
  48462. * Adds specific effects defines.
  48463. * @param defines The defines to add specifics to.
  48464. */
  48465. protected _addCustomEffectDefines(defines: string[]): void;
  48466. /**
  48467. * Checks for the readiness of the element composing the layer.
  48468. * @param subMesh the mesh to check for
  48469. * @param useInstances specify wether or not to use instances to render the mesh
  48470. * @param emissiveTexture the associated emissive texture used to generate the glow
  48471. * @return true if ready otherwise, false
  48472. */
  48473. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48474. /**
  48475. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48476. */
  48477. render(): void;
  48478. /**
  48479. * Determine if a given mesh will be used in the current effect.
  48480. * @param mesh mesh to test
  48481. * @returns true if the mesh will be used
  48482. */
  48483. hasMesh(mesh: AbstractMesh): boolean;
  48484. /**
  48485. * Returns true if the layer contains information to display, otherwise false.
  48486. * @returns true if the glow layer should be rendered
  48487. */
  48488. shouldRender(): boolean;
  48489. /**
  48490. * Returns true if the mesh should render, otherwise false.
  48491. * @param mesh The mesh to render
  48492. * @returns true if it should render otherwise false
  48493. */
  48494. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48495. /**
  48496. * Returns true if the mesh can be rendered, otherwise false.
  48497. * @param mesh The mesh to render
  48498. * @param material The material used on the mesh
  48499. * @returns true if it can be rendered otherwise false
  48500. */
  48501. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48502. /**
  48503. * Returns true if the mesh should render, otherwise false.
  48504. * @param mesh The mesh to render
  48505. * @returns true if it should render otherwise false
  48506. */
  48507. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48508. /**
  48509. * Renders the submesh passed in parameter to the generation map.
  48510. */
  48511. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48512. /**
  48513. * Rebuild the required buffers.
  48514. * @hidden Internal use only.
  48515. */
  48516. _rebuild(): void;
  48517. /**
  48518. * Dispose only the render target textures and post process.
  48519. */
  48520. private _disposeTextureAndPostProcesses;
  48521. /**
  48522. * Dispose the highlight layer and free resources.
  48523. */
  48524. dispose(): void;
  48525. /**
  48526. * Gets the class name of the effect layer
  48527. * @returns the string with the class name of the effect layer
  48528. */
  48529. getClassName(): string;
  48530. /**
  48531. * Creates an effect layer from parsed effect layer data
  48532. * @param parsedEffectLayer defines effect layer data
  48533. * @param scene defines the current scene
  48534. * @param rootUrl defines the root URL containing the effect layer information
  48535. * @returns a parsed effect Layer
  48536. */
  48537. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48538. }
  48539. }
  48540. declare module BABYLON {
  48541. interface AbstractScene {
  48542. /**
  48543. * The list of effect layers (highlights/glow) added to the scene
  48544. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48545. * @see http://doc.babylonjs.com/how_to/glow_layer
  48546. */
  48547. effectLayers: Array<EffectLayer>;
  48548. /**
  48549. * Removes the given effect layer from this scene.
  48550. * @param toRemove defines the effect layer to remove
  48551. * @returns the index of the removed effect layer
  48552. */
  48553. removeEffectLayer(toRemove: EffectLayer): number;
  48554. /**
  48555. * Adds the given effect layer to this scene
  48556. * @param newEffectLayer defines the effect layer to add
  48557. */
  48558. addEffectLayer(newEffectLayer: EffectLayer): void;
  48559. }
  48560. /**
  48561. * Defines the layer scene component responsible to manage any effect layers
  48562. * in a given scene.
  48563. */
  48564. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48565. /**
  48566. * The component name helpfull to identify the component in the list of scene components.
  48567. */
  48568. readonly name: string;
  48569. /**
  48570. * The scene the component belongs to.
  48571. */
  48572. scene: Scene;
  48573. private _engine;
  48574. private _renderEffects;
  48575. private _needStencil;
  48576. private _previousStencilState;
  48577. /**
  48578. * Creates a new instance of the component for the given scene
  48579. * @param scene Defines the scene to register the component in
  48580. */
  48581. constructor(scene: Scene);
  48582. /**
  48583. * Registers the component in a given scene
  48584. */
  48585. register(): void;
  48586. /**
  48587. * Rebuilds the elements related to this component in case of
  48588. * context lost for instance.
  48589. */
  48590. rebuild(): void;
  48591. /**
  48592. * Serializes the component data to the specified json object
  48593. * @param serializationObject The object to serialize to
  48594. */
  48595. serialize(serializationObject: any): void;
  48596. /**
  48597. * Adds all the elements from the container to the scene
  48598. * @param container the container holding the elements
  48599. */
  48600. addFromContainer(container: AbstractScene): void;
  48601. /**
  48602. * Removes all the elements in the container from the scene
  48603. * @param container contains the elements to remove
  48604. * @param dispose if the removed element should be disposed (default: false)
  48605. */
  48606. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48607. /**
  48608. * Disposes the component and the associated ressources.
  48609. */
  48610. dispose(): void;
  48611. private _isReadyForMesh;
  48612. private _renderMainTexture;
  48613. private _setStencil;
  48614. private _setStencilBack;
  48615. private _draw;
  48616. private _drawCamera;
  48617. private _drawRenderingGroup;
  48618. }
  48619. }
  48620. declare module BABYLON {
  48621. /** @hidden */
  48622. export var glowMapMergePixelShader: {
  48623. name: string;
  48624. shader: string;
  48625. };
  48626. }
  48627. declare module BABYLON {
  48628. /** @hidden */
  48629. export var glowMapMergeVertexShader: {
  48630. name: string;
  48631. shader: string;
  48632. };
  48633. }
  48634. declare module BABYLON {
  48635. interface AbstractScene {
  48636. /**
  48637. * Return a the first highlight layer of the scene with a given name.
  48638. * @param name The name of the highlight layer to look for.
  48639. * @return The highlight layer if found otherwise null.
  48640. */
  48641. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48642. }
  48643. /**
  48644. * Glow layer options. This helps customizing the behaviour
  48645. * of the glow layer.
  48646. */
  48647. export interface IGlowLayerOptions {
  48648. /**
  48649. * Multiplication factor apply to the canvas size to compute the render target size
  48650. * used to generated the glowing objects (the smaller the faster).
  48651. */
  48652. mainTextureRatio: number;
  48653. /**
  48654. * Enforces a fixed size texture to ensure resize independant blur.
  48655. */
  48656. mainTextureFixedSize?: number;
  48657. /**
  48658. * How big is the kernel of the blur texture.
  48659. */
  48660. blurKernelSize: number;
  48661. /**
  48662. * The camera attached to the layer.
  48663. */
  48664. camera: Nullable<Camera>;
  48665. /**
  48666. * Enable MSAA by chosing the number of samples.
  48667. */
  48668. mainTextureSamples?: number;
  48669. /**
  48670. * The rendering group to draw the layer in.
  48671. */
  48672. renderingGroupId: number;
  48673. }
  48674. /**
  48675. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48676. *
  48677. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48678. * glowy meshes to your scene.
  48679. *
  48680. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48681. */
  48682. export class GlowLayer extends EffectLayer {
  48683. /**
  48684. * Effect Name of the layer.
  48685. */
  48686. static readonly EffectName: string;
  48687. /**
  48688. * The default blur kernel size used for the glow.
  48689. */
  48690. static DefaultBlurKernelSize: number;
  48691. /**
  48692. * The default texture size ratio used for the glow.
  48693. */
  48694. static DefaultTextureRatio: number;
  48695. /**
  48696. * Sets the kernel size of the blur.
  48697. */
  48698. /**
  48699. * Gets the kernel size of the blur.
  48700. */
  48701. blurKernelSize: number;
  48702. /**
  48703. * Sets the glow intensity.
  48704. */
  48705. /**
  48706. * Gets the glow intensity.
  48707. */
  48708. intensity: number;
  48709. private _options;
  48710. private _intensity;
  48711. private _horizontalBlurPostprocess1;
  48712. private _verticalBlurPostprocess1;
  48713. private _horizontalBlurPostprocess2;
  48714. private _verticalBlurPostprocess2;
  48715. private _blurTexture1;
  48716. private _blurTexture2;
  48717. private _postProcesses1;
  48718. private _postProcesses2;
  48719. private _includedOnlyMeshes;
  48720. private _excludedMeshes;
  48721. /**
  48722. * Callback used to let the user override the color selection on a per mesh basis
  48723. */
  48724. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48725. /**
  48726. * Callback used to let the user override the texture selection on a per mesh basis
  48727. */
  48728. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48729. /**
  48730. * Instantiates a new glow Layer and references it to the scene.
  48731. * @param name The name of the layer
  48732. * @param scene The scene to use the layer in
  48733. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48734. */
  48735. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48736. /**
  48737. * Get the effect name of the layer.
  48738. * @return The effect name
  48739. */
  48740. getEffectName(): string;
  48741. /**
  48742. * Create the merge effect. This is the shader use to blit the information back
  48743. * to the main canvas at the end of the scene rendering.
  48744. */
  48745. protected _createMergeEffect(): Effect;
  48746. /**
  48747. * Creates the render target textures and post processes used in the glow layer.
  48748. */
  48749. protected _createTextureAndPostProcesses(): void;
  48750. /**
  48751. * Checks for the readiness of the element composing the layer.
  48752. * @param subMesh the mesh to check for
  48753. * @param useInstances specify wether or not to use instances to render the mesh
  48754. * @param emissiveTexture the associated emissive texture used to generate the glow
  48755. * @return true if ready otherwise, false
  48756. */
  48757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48758. /**
  48759. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48760. */
  48761. needStencil(): boolean;
  48762. /**
  48763. * Returns true if the mesh can be rendered, otherwise false.
  48764. * @param mesh The mesh to render
  48765. * @param material The material used on the mesh
  48766. * @returns true if it can be rendered otherwise false
  48767. */
  48768. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48769. /**
  48770. * Implementation specific of rendering the generating effect on the main canvas.
  48771. * @param effect The effect used to render through
  48772. */
  48773. protected _internalRender(effect: Effect): void;
  48774. /**
  48775. * Sets the required values for both the emissive texture and and the main color.
  48776. */
  48777. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48778. /**
  48779. * Returns true if the mesh should render, otherwise false.
  48780. * @param mesh The mesh to render
  48781. * @returns true if it should render otherwise false
  48782. */
  48783. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48784. /**
  48785. * Adds specific effects defines.
  48786. * @param defines The defines to add specifics to.
  48787. */
  48788. protected _addCustomEffectDefines(defines: string[]): void;
  48789. /**
  48790. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48791. * @param mesh The mesh to exclude from the glow layer
  48792. */
  48793. addExcludedMesh(mesh: Mesh): void;
  48794. /**
  48795. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48796. * @param mesh The mesh to remove
  48797. */
  48798. removeExcludedMesh(mesh: Mesh): void;
  48799. /**
  48800. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48801. * @param mesh The mesh to include in the glow layer
  48802. */
  48803. addIncludedOnlyMesh(mesh: Mesh): void;
  48804. /**
  48805. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48806. * @param mesh The mesh to remove
  48807. */
  48808. removeIncludedOnlyMesh(mesh: Mesh): void;
  48809. /**
  48810. * Determine if a given mesh will be used in the glow layer
  48811. * @param mesh The mesh to test
  48812. * @returns true if the mesh will be highlighted by the current glow layer
  48813. */
  48814. hasMesh(mesh: AbstractMesh): boolean;
  48815. /**
  48816. * Free any resources and references associated to a mesh.
  48817. * Internal use
  48818. * @param mesh The mesh to free.
  48819. * @hidden
  48820. */
  48821. _disposeMesh(mesh: Mesh): void;
  48822. /**
  48823. * Gets the class name of the effect layer
  48824. * @returns the string with the class name of the effect layer
  48825. */
  48826. getClassName(): string;
  48827. /**
  48828. * Serializes this glow layer
  48829. * @returns a serialized glow layer object
  48830. */
  48831. serialize(): any;
  48832. /**
  48833. * Creates a Glow Layer from parsed glow layer data
  48834. * @param parsedGlowLayer defines glow layer data
  48835. * @param scene defines the current scene
  48836. * @param rootUrl defines the root URL containing the glow layer information
  48837. * @returns a parsed Glow Layer
  48838. */
  48839. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48840. }
  48841. }
  48842. declare module BABYLON {
  48843. /** @hidden */
  48844. export var glowBlurPostProcessPixelShader: {
  48845. name: string;
  48846. shader: string;
  48847. };
  48848. }
  48849. declare module BABYLON {
  48850. interface AbstractScene {
  48851. /**
  48852. * Return a the first highlight layer of the scene with a given name.
  48853. * @param name The name of the highlight layer to look for.
  48854. * @return The highlight layer if found otherwise null.
  48855. */
  48856. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48857. }
  48858. /**
  48859. * Highlight layer options. This helps customizing the behaviour
  48860. * of the highlight layer.
  48861. */
  48862. export interface IHighlightLayerOptions {
  48863. /**
  48864. * Multiplication factor apply to the canvas size to compute the render target size
  48865. * used to generated the glowing objects (the smaller the faster).
  48866. */
  48867. mainTextureRatio: number;
  48868. /**
  48869. * Enforces a fixed size texture to ensure resize independant blur.
  48870. */
  48871. mainTextureFixedSize?: number;
  48872. /**
  48873. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48874. * of the picture to blur (the smaller the faster).
  48875. */
  48876. blurTextureSizeRatio: number;
  48877. /**
  48878. * How big in texel of the blur texture is the vertical blur.
  48879. */
  48880. blurVerticalSize: number;
  48881. /**
  48882. * How big in texel of the blur texture is the horizontal blur.
  48883. */
  48884. blurHorizontalSize: number;
  48885. /**
  48886. * Alpha blending mode used to apply the blur. Default is combine.
  48887. */
  48888. alphaBlendingMode: number;
  48889. /**
  48890. * The camera attached to the layer.
  48891. */
  48892. camera: Nullable<Camera>;
  48893. /**
  48894. * Should we display highlight as a solid stroke?
  48895. */
  48896. isStroke?: boolean;
  48897. /**
  48898. * The rendering group to draw the layer in.
  48899. */
  48900. renderingGroupId: number;
  48901. }
  48902. /**
  48903. * The highlight layer Helps adding a glow effect around a mesh.
  48904. *
  48905. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48906. * glowy meshes to your scene.
  48907. *
  48908. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48909. */
  48910. export class HighlightLayer extends EffectLayer {
  48911. name: string;
  48912. /**
  48913. * Effect Name of the highlight layer.
  48914. */
  48915. static readonly EffectName: string;
  48916. /**
  48917. * The neutral color used during the preparation of the glow effect.
  48918. * This is black by default as the blend operation is a blend operation.
  48919. */
  48920. static NeutralColor: Color4;
  48921. /**
  48922. * Stencil value used for glowing meshes.
  48923. */
  48924. static GlowingMeshStencilReference: number;
  48925. /**
  48926. * Stencil value used for the other meshes in the scene.
  48927. */
  48928. static NormalMeshStencilReference: number;
  48929. /**
  48930. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48931. */
  48932. innerGlow: boolean;
  48933. /**
  48934. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48935. */
  48936. outerGlow: boolean;
  48937. /**
  48938. * Specifies the horizontal size of the blur.
  48939. */
  48940. /**
  48941. * Gets the horizontal size of the blur.
  48942. */
  48943. blurHorizontalSize: number;
  48944. /**
  48945. * Specifies the vertical size of the blur.
  48946. */
  48947. /**
  48948. * Gets the vertical size of the blur.
  48949. */
  48950. blurVerticalSize: number;
  48951. /**
  48952. * An event triggered when the highlight layer is being blurred.
  48953. */
  48954. onBeforeBlurObservable: Observable<HighlightLayer>;
  48955. /**
  48956. * An event triggered when the highlight layer has been blurred.
  48957. */
  48958. onAfterBlurObservable: Observable<HighlightLayer>;
  48959. private _instanceGlowingMeshStencilReference;
  48960. private _options;
  48961. private _downSamplePostprocess;
  48962. private _horizontalBlurPostprocess;
  48963. private _verticalBlurPostprocess;
  48964. private _blurTexture;
  48965. private _meshes;
  48966. private _excludedMeshes;
  48967. /**
  48968. * Instantiates a new highlight Layer and references it to the scene..
  48969. * @param name The name of the layer
  48970. * @param scene The scene to use the layer in
  48971. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48972. */
  48973. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48974. /**
  48975. * Get the effect name of the layer.
  48976. * @return The effect name
  48977. */
  48978. getEffectName(): string;
  48979. /**
  48980. * Create the merge effect. This is the shader use to blit the information back
  48981. * to the main canvas at the end of the scene rendering.
  48982. */
  48983. protected _createMergeEffect(): Effect;
  48984. /**
  48985. * Creates the render target textures and post processes used in the highlight layer.
  48986. */
  48987. protected _createTextureAndPostProcesses(): void;
  48988. /**
  48989. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48990. */
  48991. needStencil(): boolean;
  48992. /**
  48993. * Checks for the readiness of the element composing the layer.
  48994. * @param subMesh the mesh to check for
  48995. * @param useInstances specify wether or not to use instances to render the mesh
  48996. * @param emissiveTexture the associated emissive texture used to generate the glow
  48997. * @return true if ready otherwise, false
  48998. */
  48999. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49000. /**
  49001. * Implementation specific of rendering the generating effect on the main canvas.
  49002. * @param effect The effect used to render through
  49003. */
  49004. protected _internalRender(effect: Effect): void;
  49005. /**
  49006. * Returns true if the layer contains information to display, otherwise false.
  49007. */
  49008. shouldRender(): boolean;
  49009. /**
  49010. * Returns true if the mesh should render, otherwise false.
  49011. * @param mesh The mesh to render
  49012. * @returns true if it should render otherwise false
  49013. */
  49014. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49015. /**
  49016. * Sets the required values for both the emissive texture and and the main color.
  49017. */
  49018. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49019. /**
  49020. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49021. * @param mesh The mesh to exclude from the highlight layer
  49022. */
  49023. addExcludedMesh(mesh: Mesh): void;
  49024. /**
  49025. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49026. * @param mesh The mesh to highlight
  49027. */
  49028. removeExcludedMesh(mesh: Mesh): void;
  49029. /**
  49030. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49031. * @param mesh mesh to test
  49032. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49033. */
  49034. hasMesh(mesh: AbstractMesh): boolean;
  49035. /**
  49036. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49037. * @param mesh The mesh to highlight
  49038. * @param color The color of the highlight
  49039. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49040. */
  49041. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49042. /**
  49043. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49044. * @param mesh The mesh to highlight
  49045. */
  49046. removeMesh(mesh: Mesh): void;
  49047. /**
  49048. * Force the stencil to the normal expected value for none glowing parts
  49049. */
  49050. private _defaultStencilReference;
  49051. /**
  49052. * Free any resources and references associated to a mesh.
  49053. * Internal use
  49054. * @param mesh The mesh to free.
  49055. * @hidden
  49056. */
  49057. _disposeMesh(mesh: Mesh): void;
  49058. /**
  49059. * Dispose the highlight layer and free resources.
  49060. */
  49061. dispose(): void;
  49062. /**
  49063. * Gets the class name of the effect layer
  49064. * @returns the string with the class name of the effect layer
  49065. */
  49066. getClassName(): string;
  49067. /**
  49068. * Serializes this Highlight layer
  49069. * @returns a serialized Highlight layer object
  49070. */
  49071. serialize(): any;
  49072. /**
  49073. * Creates a Highlight layer from parsed Highlight layer data
  49074. * @param parsedHightlightLayer defines the Highlight layer data
  49075. * @param scene defines the current scene
  49076. * @param rootUrl defines the root URL containing the Highlight layer information
  49077. * @returns a parsed Highlight layer
  49078. */
  49079. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49080. }
  49081. }
  49082. declare module BABYLON {
  49083. interface AbstractScene {
  49084. /**
  49085. * The list of layers (background and foreground) of the scene
  49086. */
  49087. layers: Array<Layer>;
  49088. }
  49089. /**
  49090. * Defines the layer scene component responsible to manage any layers
  49091. * in a given scene.
  49092. */
  49093. export class LayerSceneComponent implements ISceneComponent {
  49094. /**
  49095. * The component name helpfull to identify the component in the list of scene components.
  49096. */
  49097. readonly name: string;
  49098. /**
  49099. * The scene the component belongs to.
  49100. */
  49101. scene: Scene;
  49102. private _engine;
  49103. /**
  49104. * Creates a new instance of the component for the given scene
  49105. * @param scene Defines the scene to register the component in
  49106. */
  49107. constructor(scene: Scene);
  49108. /**
  49109. * Registers the component in a given scene
  49110. */
  49111. register(): void;
  49112. /**
  49113. * Rebuilds the elements related to this component in case of
  49114. * context lost for instance.
  49115. */
  49116. rebuild(): void;
  49117. /**
  49118. * Disposes the component and the associated ressources.
  49119. */
  49120. dispose(): void;
  49121. private _draw;
  49122. private _drawCameraPredicate;
  49123. private _drawCameraBackground;
  49124. private _drawCameraForeground;
  49125. private _drawRenderTargetPredicate;
  49126. private _drawRenderTargetBackground;
  49127. private _drawRenderTargetForeground;
  49128. /**
  49129. * Adds all the elements from the container to the scene
  49130. * @param container the container holding the elements
  49131. */
  49132. addFromContainer(container: AbstractScene): void;
  49133. /**
  49134. * Removes all the elements in the container from the scene
  49135. * @param container contains the elements to remove
  49136. * @param dispose if the removed element should be disposed (default: false)
  49137. */
  49138. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49139. }
  49140. }
  49141. declare module BABYLON {
  49142. /** @hidden */
  49143. export var layerPixelShader: {
  49144. name: string;
  49145. shader: string;
  49146. };
  49147. }
  49148. declare module BABYLON {
  49149. /** @hidden */
  49150. export var layerVertexShader: {
  49151. name: string;
  49152. shader: string;
  49153. };
  49154. }
  49155. declare module BABYLON {
  49156. /**
  49157. * This represents a full screen 2d layer.
  49158. * This can be useful to display a picture in the background of your scene for instance.
  49159. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49160. */
  49161. export class Layer {
  49162. /**
  49163. * Define the name of the layer.
  49164. */
  49165. name: string;
  49166. /**
  49167. * Define the texture the layer should display.
  49168. */
  49169. texture: Nullable<Texture>;
  49170. /**
  49171. * Is the layer in background or foreground.
  49172. */
  49173. isBackground: boolean;
  49174. /**
  49175. * Define the color of the layer (instead of texture).
  49176. */
  49177. color: Color4;
  49178. /**
  49179. * Define the scale of the layer in order to zoom in out of the texture.
  49180. */
  49181. scale: Vector2;
  49182. /**
  49183. * Define an offset for the layer in order to shift the texture.
  49184. */
  49185. offset: Vector2;
  49186. /**
  49187. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49188. */
  49189. alphaBlendingMode: number;
  49190. /**
  49191. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49192. * Alpha test will not mix with the background color in case of transparency.
  49193. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49194. */
  49195. alphaTest: boolean;
  49196. /**
  49197. * Define a mask to restrict the layer to only some of the scene cameras.
  49198. */
  49199. layerMask: number;
  49200. /**
  49201. * Define the list of render target the layer is visible into.
  49202. */
  49203. renderTargetTextures: RenderTargetTexture[];
  49204. /**
  49205. * Define if the layer is only used in renderTarget or if it also
  49206. * renders in the main frame buffer of the canvas.
  49207. */
  49208. renderOnlyInRenderTargetTextures: boolean;
  49209. private _scene;
  49210. private _vertexBuffers;
  49211. private _indexBuffer;
  49212. private _effect;
  49213. private _alphaTestEffect;
  49214. /**
  49215. * An event triggered when the layer is disposed.
  49216. */
  49217. onDisposeObservable: Observable<Layer>;
  49218. private _onDisposeObserver;
  49219. /**
  49220. * Back compatibility with callback before the onDisposeObservable existed.
  49221. * The set callback will be triggered when the layer has been disposed.
  49222. */
  49223. onDispose: () => void;
  49224. /**
  49225. * An event triggered before rendering the scene
  49226. */
  49227. onBeforeRenderObservable: Observable<Layer>;
  49228. private _onBeforeRenderObserver;
  49229. /**
  49230. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49231. * The set callback will be triggered just before rendering the layer.
  49232. */
  49233. onBeforeRender: () => void;
  49234. /**
  49235. * An event triggered after rendering the scene
  49236. */
  49237. onAfterRenderObservable: Observable<Layer>;
  49238. private _onAfterRenderObserver;
  49239. /**
  49240. * Back compatibility with callback before the onAfterRenderObservable existed.
  49241. * The set callback will be triggered just after rendering the layer.
  49242. */
  49243. onAfterRender: () => void;
  49244. /**
  49245. * Instantiates a new layer.
  49246. * This represents a full screen 2d layer.
  49247. * This can be useful to display a picture in the background of your scene for instance.
  49248. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49249. * @param name Define the name of the layer in the scene
  49250. * @param imgUrl Define the url of the texture to display in the layer
  49251. * @param scene Define the scene the layer belongs to
  49252. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49253. * @param color Defines a color for the layer
  49254. */
  49255. constructor(
  49256. /**
  49257. * Define the name of the layer.
  49258. */
  49259. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49260. private _createIndexBuffer;
  49261. /** @hidden */
  49262. _rebuild(): void;
  49263. /**
  49264. * Renders the layer in the scene.
  49265. */
  49266. render(): void;
  49267. /**
  49268. * Disposes and releases the associated ressources.
  49269. */
  49270. dispose(): void;
  49271. }
  49272. }
  49273. declare module BABYLON {
  49274. /** @hidden */
  49275. export var lensFlarePixelShader: {
  49276. name: string;
  49277. shader: string;
  49278. };
  49279. }
  49280. declare module BABYLON {
  49281. /** @hidden */
  49282. export var lensFlareVertexShader: {
  49283. name: string;
  49284. shader: string;
  49285. };
  49286. }
  49287. declare module BABYLON {
  49288. /**
  49289. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49290. * It is usually composed of several `lensFlare`.
  49291. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49292. */
  49293. export class LensFlareSystem {
  49294. /**
  49295. * Define the name of the lens flare system
  49296. */
  49297. name: string;
  49298. /**
  49299. * List of lens flares used in this system.
  49300. */
  49301. lensFlares: LensFlare[];
  49302. /**
  49303. * Define a limit from the border the lens flare can be visible.
  49304. */
  49305. borderLimit: number;
  49306. /**
  49307. * Define a viewport border we do not want to see the lens flare in.
  49308. */
  49309. viewportBorder: number;
  49310. /**
  49311. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49312. */
  49313. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49314. /**
  49315. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49316. */
  49317. layerMask: number;
  49318. /**
  49319. * Define the id of the lens flare system in the scene.
  49320. * (equal to name by default)
  49321. */
  49322. id: string;
  49323. private _scene;
  49324. private _emitter;
  49325. private _vertexBuffers;
  49326. private _indexBuffer;
  49327. private _effect;
  49328. private _positionX;
  49329. private _positionY;
  49330. private _isEnabled;
  49331. /** @hidden */
  49332. static _SceneComponentInitialization: (scene: Scene) => void;
  49333. /**
  49334. * Instantiates a lens flare system.
  49335. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49336. * It is usually composed of several `lensFlare`.
  49337. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49338. * @param name Define the name of the lens flare system in the scene
  49339. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49340. * @param scene Define the scene the lens flare system belongs to
  49341. */
  49342. constructor(
  49343. /**
  49344. * Define the name of the lens flare system
  49345. */
  49346. name: string, emitter: any, scene: Scene);
  49347. /**
  49348. * Define if the lens flare system is enabled.
  49349. */
  49350. isEnabled: boolean;
  49351. /**
  49352. * Get the scene the effects belongs to.
  49353. * @returns the scene holding the lens flare system
  49354. */
  49355. getScene(): Scene;
  49356. /**
  49357. * Get the emitter of the lens flare system.
  49358. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49359. * @returns the emitter of the lens flare system
  49360. */
  49361. getEmitter(): any;
  49362. /**
  49363. * Set the emitter of the lens flare system.
  49364. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49365. * @param newEmitter Define the new emitter of the system
  49366. */
  49367. setEmitter(newEmitter: any): void;
  49368. /**
  49369. * Get the lens flare system emitter position.
  49370. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49371. * @returns the position
  49372. */
  49373. getEmitterPosition(): Vector3;
  49374. /**
  49375. * @hidden
  49376. */
  49377. computeEffectivePosition(globalViewport: Viewport): boolean;
  49378. /** @hidden */
  49379. _isVisible(): boolean;
  49380. /**
  49381. * @hidden
  49382. */
  49383. render(): boolean;
  49384. /**
  49385. * Dispose and release the lens flare with its associated resources.
  49386. */
  49387. dispose(): void;
  49388. /**
  49389. * Parse a lens flare system from a JSON repressentation
  49390. * @param parsedLensFlareSystem Define the JSON to parse
  49391. * @param scene Define the scene the parsed system should be instantiated in
  49392. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49393. * @returns the parsed system
  49394. */
  49395. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49396. /**
  49397. * Serialize the current Lens Flare System into a JSON representation.
  49398. * @returns the serialized JSON
  49399. */
  49400. serialize(): any;
  49401. }
  49402. }
  49403. declare module BABYLON {
  49404. /**
  49405. * This represents one of the lens effect in a `lensFlareSystem`.
  49406. * It controls one of the indiviual texture used in the effect.
  49407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49408. */
  49409. export class LensFlare {
  49410. /**
  49411. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49412. */
  49413. size: number;
  49414. /**
  49415. * 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.
  49416. */
  49417. position: number;
  49418. /**
  49419. * Define the lens color.
  49420. */
  49421. color: Color3;
  49422. /**
  49423. * Define the lens texture.
  49424. */
  49425. texture: Nullable<Texture>;
  49426. /**
  49427. * Define the alpha mode to render this particular lens.
  49428. */
  49429. alphaMode: number;
  49430. private _system;
  49431. /**
  49432. * Creates a new Lens Flare.
  49433. * This represents one of the lens effect in a `lensFlareSystem`.
  49434. * It controls one of the indiviual texture used in the effect.
  49435. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49436. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49437. * @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.
  49438. * @param color Define the lens color
  49439. * @param imgUrl Define the lens texture url
  49440. * @param system Define the `lensFlareSystem` this flare is part of
  49441. * @returns The newly created Lens Flare
  49442. */
  49443. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49444. /**
  49445. * Instantiates a new Lens Flare.
  49446. * This represents one of the lens effect in a `lensFlareSystem`.
  49447. * It controls one of the indiviual texture used in the effect.
  49448. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49449. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49450. * @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.
  49451. * @param color Define the lens color
  49452. * @param imgUrl Define the lens texture url
  49453. * @param system Define the `lensFlareSystem` this flare is part of
  49454. */
  49455. constructor(
  49456. /**
  49457. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49458. */
  49459. size: number,
  49460. /**
  49461. * 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.
  49462. */
  49463. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49464. /**
  49465. * Dispose and release the lens flare with its associated resources.
  49466. */
  49467. dispose(): void;
  49468. }
  49469. }
  49470. declare module BABYLON {
  49471. interface AbstractScene {
  49472. /**
  49473. * The list of lens flare system added to the scene
  49474. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49475. */
  49476. lensFlareSystems: Array<LensFlareSystem>;
  49477. /**
  49478. * Removes the given lens flare system from this scene.
  49479. * @param toRemove The lens flare system to remove
  49480. * @returns The index of the removed lens flare system
  49481. */
  49482. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49483. /**
  49484. * Adds the given lens flare system to this scene
  49485. * @param newLensFlareSystem The lens flare system to add
  49486. */
  49487. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49488. /**
  49489. * Gets a lens flare system using its name
  49490. * @param name defines the name to look for
  49491. * @returns the lens flare system or null if not found
  49492. */
  49493. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49494. /**
  49495. * Gets a lens flare system using its id
  49496. * @param id defines the id to look for
  49497. * @returns the lens flare system or null if not found
  49498. */
  49499. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49500. }
  49501. /**
  49502. * Defines the lens flare scene component responsible to manage any lens flares
  49503. * in a given scene.
  49504. */
  49505. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49506. /**
  49507. * The component name helpfull to identify the component in the list of scene components.
  49508. */
  49509. readonly name: string;
  49510. /**
  49511. * The scene the component belongs to.
  49512. */
  49513. scene: Scene;
  49514. /**
  49515. * Creates a new instance of the component for the given scene
  49516. * @param scene Defines the scene to register the component in
  49517. */
  49518. constructor(scene: Scene);
  49519. /**
  49520. * Registers the component in a given scene
  49521. */
  49522. register(): void;
  49523. /**
  49524. * Rebuilds the elements related to this component in case of
  49525. * context lost for instance.
  49526. */
  49527. rebuild(): void;
  49528. /**
  49529. * Adds all the elements from the container to the scene
  49530. * @param container the container holding the elements
  49531. */
  49532. addFromContainer(container: AbstractScene): void;
  49533. /**
  49534. * Removes all the elements in the container from the scene
  49535. * @param container contains the elements to remove
  49536. * @param dispose if the removed element should be disposed (default: false)
  49537. */
  49538. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49539. /**
  49540. * Serializes the component data to the specified json object
  49541. * @param serializationObject The object to serialize to
  49542. */
  49543. serialize(serializationObject: any): void;
  49544. /**
  49545. * Disposes the component and the associated ressources.
  49546. */
  49547. dispose(): void;
  49548. private _draw;
  49549. }
  49550. }
  49551. declare module BABYLON {
  49552. /**
  49553. * Defines the shadow generator component responsible to manage any shadow generators
  49554. * in a given scene.
  49555. */
  49556. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49557. /**
  49558. * The component name helpfull to identify the component in the list of scene components.
  49559. */
  49560. readonly name: string;
  49561. /**
  49562. * The scene the component belongs to.
  49563. */
  49564. scene: Scene;
  49565. /**
  49566. * Creates a new instance of the component for the given scene
  49567. * @param scene Defines the scene to register the component in
  49568. */
  49569. constructor(scene: Scene);
  49570. /**
  49571. * Registers the component in a given scene
  49572. */
  49573. register(): void;
  49574. /**
  49575. * Rebuilds the elements related to this component in case of
  49576. * context lost for instance.
  49577. */
  49578. rebuild(): void;
  49579. /**
  49580. * Serializes the component data to the specified json object
  49581. * @param serializationObject The object to serialize to
  49582. */
  49583. serialize(serializationObject: any): void;
  49584. /**
  49585. * Adds all the elements from the container to the scene
  49586. * @param container the container holding the elements
  49587. */
  49588. addFromContainer(container: AbstractScene): void;
  49589. /**
  49590. * Removes all the elements in the container from the scene
  49591. * @param container contains the elements to remove
  49592. * @param dispose if the removed element should be disposed (default: false)
  49593. */
  49594. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49595. /**
  49596. * Rebuilds the elements related to this component in case of
  49597. * context lost for instance.
  49598. */
  49599. dispose(): void;
  49600. private _gatherRenderTargets;
  49601. }
  49602. }
  49603. declare module BABYLON {
  49604. /**
  49605. * A point light is a light defined by an unique point in world space.
  49606. * The light is emitted in every direction from this point.
  49607. * A good example of a point light is a standard light bulb.
  49608. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49609. */
  49610. export class PointLight extends ShadowLight {
  49611. private _shadowAngle;
  49612. /**
  49613. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49614. * This specifies what angle the shadow will use to be created.
  49615. *
  49616. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49617. */
  49618. /**
  49619. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49620. * This specifies what angle the shadow will use to be created.
  49621. *
  49622. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49623. */
  49624. shadowAngle: number;
  49625. /**
  49626. * Gets the direction if it has been set.
  49627. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49628. */
  49629. /**
  49630. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49631. */
  49632. direction: Vector3;
  49633. /**
  49634. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49635. * A PointLight emits the light in every direction.
  49636. * It can cast shadows.
  49637. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49638. * ```javascript
  49639. * var pointLight = new PointLight("pl", camera.position, scene);
  49640. * ```
  49641. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49642. * @param name The light friendly name
  49643. * @param position The position of the point light in the scene
  49644. * @param scene The scene the lights belongs to
  49645. */
  49646. constructor(name: string, position: Vector3, scene: Scene);
  49647. /**
  49648. * Returns the string "PointLight"
  49649. * @returns the class name
  49650. */
  49651. getClassName(): string;
  49652. /**
  49653. * Returns the integer 0.
  49654. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49655. */
  49656. getTypeID(): number;
  49657. /**
  49658. * Specifies wether or not the shadowmap should be a cube texture.
  49659. * @returns true if the shadowmap needs to be a cube texture.
  49660. */
  49661. needCube(): boolean;
  49662. /**
  49663. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49664. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49665. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49666. */
  49667. getShadowDirection(faceIndex?: number): Vector3;
  49668. /**
  49669. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49670. * - fov = PI / 2
  49671. * - aspect ratio : 1.0
  49672. * - z-near and far equal to the active camera minZ and maxZ.
  49673. * Returns the PointLight.
  49674. */
  49675. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49676. protected _buildUniformLayout(): void;
  49677. /**
  49678. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49679. * @param effect The effect to update
  49680. * @param lightIndex The index of the light in the effect to update
  49681. * @returns The point light
  49682. */
  49683. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49684. /**
  49685. * Prepares the list of defines specific to the light type.
  49686. * @param defines the list of defines
  49687. * @param lightIndex defines the index of the light for the effect
  49688. */
  49689. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49690. }
  49691. }
  49692. declare module BABYLON {
  49693. /**
  49694. * Header information of HDR texture files.
  49695. */
  49696. export interface HDRInfo {
  49697. /**
  49698. * The height of the texture in pixels.
  49699. */
  49700. height: number;
  49701. /**
  49702. * The width of the texture in pixels.
  49703. */
  49704. width: number;
  49705. /**
  49706. * The index of the beginning of the data in the binary file.
  49707. */
  49708. dataPosition: number;
  49709. }
  49710. /**
  49711. * This groups tools to convert HDR texture to native colors array.
  49712. */
  49713. export class HDRTools {
  49714. private static Ldexp;
  49715. private static Rgbe2float;
  49716. private static readStringLine;
  49717. /**
  49718. * Reads header information from an RGBE texture stored in a native array.
  49719. * More information on this format are available here:
  49720. * https://en.wikipedia.org/wiki/RGBE_image_format
  49721. *
  49722. * @param uint8array The binary file stored in native array.
  49723. * @return The header information.
  49724. */
  49725. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49726. /**
  49727. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49728. * This RGBE texture needs to store the information as a panorama.
  49729. *
  49730. * More information on this format are available here:
  49731. * https://en.wikipedia.org/wiki/RGBE_image_format
  49732. *
  49733. * @param buffer The binary file stored in an array buffer.
  49734. * @param size The expected size of the extracted cubemap.
  49735. * @return The Cube Map information.
  49736. */
  49737. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49738. /**
  49739. * Returns the pixels data extracted from an RGBE texture.
  49740. * This pixels will be stored left to right up to down in the R G B order in one array.
  49741. *
  49742. * More information on this format are available here:
  49743. * https://en.wikipedia.org/wiki/RGBE_image_format
  49744. *
  49745. * @param uint8array The binary file stored in an array buffer.
  49746. * @param hdrInfo The header information of the file.
  49747. * @return The pixels data in RGB right to left up to down order.
  49748. */
  49749. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49750. private static RGBE_ReadPixels_RLE;
  49751. }
  49752. }
  49753. declare module BABYLON {
  49754. /**
  49755. * This represents a texture coming from an HDR input.
  49756. *
  49757. * The only supported format is currently panorama picture stored in RGBE format.
  49758. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49759. */
  49760. export class HDRCubeTexture extends BaseTexture {
  49761. private static _facesMapping;
  49762. private _generateHarmonics;
  49763. private _noMipmap;
  49764. private _textureMatrix;
  49765. private _size;
  49766. private _onLoad;
  49767. private _onError;
  49768. /**
  49769. * The texture URL.
  49770. */
  49771. url: string;
  49772. /**
  49773. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49774. */
  49775. coordinatesMode: number;
  49776. protected _isBlocking: boolean;
  49777. /**
  49778. * Sets wether or not the texture is blocking during loading.
  49779. */
  49780. /**
  49781. * Gets wether or not the texture is blocking during loading.
  49782. */
  49783. isBlocking: boolean;
  49784. protected _rotationY: number;
  49785. /**
  49786. * Sets texture matrix rotation angle around Y axis in radians.
  49787. */
  49788. /**
  49789. * Gets texture matrix rotation angle around Y axis radians.
  49790. */
  49791. rotationY: number;
  49792. /**
  49793. * Gets or sets the center of the bounding box associated with the cube texture
  49794. * It must define where the camera used to render the texture was set
  49795. */
  49796. boundingBoxPosition: Vector3;
  49797. private _boundingBoxSize;
  49798. /**
  49799. * Gets or sets the size of the bounding box associated with the cube texture
  49800. * When defined, the cubemap will switch to local mode
  49801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49802. * @example https://www.babylonjs-playground.com/#RNASML
  49803. */
  49804. boundingBoxSize: Vector3;
  49805. /**
  49806. * Instantiates an HDRTexture from the following parameters.
  49807. *
  49808. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49809. * @param scene The scene the texture will be used in
  49810. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49811. * @param noMipmap Forces to not generate the mipmap if true
  49812. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49813. * @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)
  49814. * @param reserved Reserved flag for internal use.
  49815. */
  49816. 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>);
  49817. /**
  49818. * Get the current class name of the texture useful for serialization or dynamic coding.
  49819. * @returns "HDRCubeTexture"
  49820. */
  49821. getClassName(): string;
  49822. /**
  49823. * Occurs when the file is raw .hdr file.
  49824. */
  49825. private loadTexture;
  49826. clone(): HDRCubeTexture;
  49827. delayLoad(): void;
  49828. /**
  49829. * Get the texture reflection matrix used to rotate/transform the reflection.
  49830. * @returns the reflection matrix
  49831. */
  49832. getReflectionTextureMatrix(): Matrix;
  49833. /**
  49834. * Set the texture reflection matrix used to rotate/transform the reflection.
  49835. * @param value Define the reflection matrix to set
  49836. */
  49837. setReflectionTextureMatrix(value: Matrix): void;
  49838. /**
  49839. * Parses a JSON representation of an HDR Texture in order to create the texture
  49840. * @param parsedTexture Define the JSON representation
  49841. * @param scene Define the scene the texture should be created in
  49842. * @param rootUrl Define the root url in case we need to load relative dependencies
  49843. * @returns the newly created texture after parsing
  49844. */
  49845. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49846. serialize(): any;
  49847. }
  49848. }
  49849. declare module BABYLON {
  49850. /**
  49851. * Class used to control physics engine
  49852. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49853. */
  49854. export class PhysicsEngine implements IPhysicsEngine {
  49855. private _physicsPlugin;
  49856. /**
  49857. * Global value used to control the smallest number supported by the simulation
  49858. */
  49859. static Epsilon: number;
  49860. private _impostors;
  49861. private _joints;
  49862. /**
  49863. * Gets the gravity vector used by the simulation
  49864. */
  49865. gravity: Vector3;
  49866. /**
  49867. * Factory used to create the default physics plugin.
  49868. * @returns The default physics plugin
  49869. */
  49870. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49871. /**
  49872. * Creates a new Physics Engine
  49873. * @param gravity defines the gravity vector used by the simulation
  49874. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49875. */
  49876. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49877. /**
  49878. * Sets the gravity vector used by the simulation
  49879. * @param gravity defines the gravity vector to use
  49880. */
  49881. setGravity(gravity: Vector3): void;
  49882. /**
  49883. * Set the time step of the physics engine.
  49884. * Default is 1/60.
  49885. * To slow it down, enter 1/600 for example.
  49886. * To speed it up, 1/30
  49887. * @param newTimeStep defines the new timestep to apply to this world.
  49888. */
  49889. setTimeStep(newTimeStep?: number): void;
  49890. /**
  49891. * Get the time step of the physics engine.
  49892. * @returns the current time step
  49893. */
  49894. getTimeStep(): number;
  49895. /**
  49896. * Release all resources
  49897. */
  49898. dispose(): void;
  49899. /**
  49900. * Gets the name of the current physics plugin
  49901. * @returns the name of the plugin
  49902. */
  49903. getPhysicsPluginName(): string;
  49904. /**
  49905. * Adding a new impostor for the impostor tracking.
  49906. * This will be done by the impostor itself.
  49907. * @param impostor the impostor to add
  49908. */
  49909. addImpostor(impostor: PhysicsImpostor): void;
  49910. /**
  49911. * Remove an impostor from the engine.
  49912. * This impostor and its mesh will not longer be updated by the physics engine.
  49913. * @param impostor the impostor to remove
  49914. */
  49915. removeImpostor(impostor: PhysicsImpostor): void;
  49916. /**
  49917. * Add a joint to the physics engine
  49918. * @param mainImpostor defines the main impostor to which the joint is added.
  49919. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49920. * @param joint defines the joint that will connect both impostors.
  49921. */
  49922. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49923. /**
  49924. * Removes a joint from the simulation
  49925. * @param mainImpostor defines the impostor used with the joint
  49926. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49927. * @param joint defines the joint to remove
  49928. */
  49929. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49930. /**
  49931. * Called by the scene. No need to call it.
  49932. * @param delta defines the timespam between frames
  49933. */
  49934. _step(delta: number): void;
  49935. /**
  49936. * Gets the current plugin used to run the simulation
  49937. * @returns current plugin
  49938. */
  49939. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49940. /**
  49941. * Gets the list of physic impostors
  49942. * @returns an array of PhysicsImpostor
  49943. */
  49944. getImpostors(): Array<PhysicsImpostor>;
  49945. /**
  49946. * Gets the impostor for a physics enabled object
  49947. * @param object defines the object impersonated by the impostor
  49948. * @returns the PhysicsImpostor or null if not found
  49949. */
  49950. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49951. /**
  49952. * Gets the impostor for a physics body object
  49953. * @param body defines physics body used by the impostor
  49954. * @returns the PhysicsImpostor or null if not found
  49955. */
  49956. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49957. /**
  49958. * Does a raycast in the physics world
  49959. * @param from when should the ray start?
  49960. * @param to when should the ray end?
  49961. * @returns PhysicsRaycastResult
  49962. */
  49963. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49964. }
  49965. }
  49966. declare module BABYLON {
  49967. /** @hidden */
  49968. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49969. private _useDeltaForWorldStep;
  49970. world: any;
  49971. name: string;
  49972. private _physicsMaterials;
  49973. private _fixedTimeStep;
  49974. private _cannonRaycastResult;
  49975. private _raycastResult;
  49976. private _physicsBodysToRemoveAfterStep;
  49977. BJSCANNON: any;
  49978. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49979. setGravity(gravity: Vector3): void;
  49980. setTimeStep(timeStep: number): void;
  49981. getTimeStep(): number;
  49982. executeStep(delta: number): void;
  49983. private _removeMarkedPhysicsBodiesFromWorld;
  49984. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49985. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49986. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49987. private _processChildMeshes;
  49988. removePhysicsBody(impostor: PhysicsImpostor): void;
  49989. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49990. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49991. private _addMaterial;
  49992. private _checkWithEpsilon;
  49993. private _createShape;
  49994. private _createHeightmap;
  49995. private _minus90X;
  49996. private _plus90X;
  49997. private _tmpPosition;
  49998. private _tmpDeltaPosition;
  49999. private _tmpUnityRotation;
  50000. private _updatePhysicsBodyTransformation;
  50001. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50002. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50003. isSupported(): boolean;
  50004. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50005. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50006. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50007. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50008. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50009. getBodyMass(impostor: PhysicsImpostor): number;
  50010. getBodyFriction(impostor: PhysicsImpostor): number;
  50011. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50012. getBodyRestitution(impostor: PhysicsImpostor): number;
  50013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50014. sleepBody(impostor: PhysicsImpostor): void;
  50015. wakeUpBody(impostor: PhysicsImpostor): void;
  50016. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50017. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50018. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50019. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50020. getRadius(impostor: PhysicsImpostor): number;
  50021. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50022. dispose(): void;
  50023. private _extendNamespace;
  50024. /**
  50025. * Does a raycast in the physics world
  50026. * @param from when should the ray start?
  50027. * @param to when should the ray end?
  50028. * @returns PhysicsRaycastResult
  50029. */
  50030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50031. }
  50032. }
  50033. declare module BABYLON {
  50034. /** @hidden */
  50035. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50036. world: any;
  50037. name: string;
  50038. BJSOIMO: any;
  50039. private _raycastResult;
  50040. constructor(iterations?: number, oimoInjection?: any);
  50041. setGravity(gravity: Vector3): void;
  50042. setTimeStep(timeStep: number): void;
  50043. getTimeStep(): number;
  50044. private _tmpImpostorsArray;
  50045. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50046. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50047. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50049. private _tmpPositionVector;
  50050. removePhysicsBody(impostor: PhysicsImpostor): void;
  50051. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50052. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50053. isSupported(): boolean;
  50054. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50055. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50056. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50057. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50058. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50059. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50060. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50061. getBodyMass(impostor: PhysicsImpostor): number;
  50062. getBodyFriction(impostor: PhysicsImpostor): number;
  50063. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50064. getBodyRestitution(impostor: PhysicsImpostor): number;
  50065. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50066. sleepBody(impostor: PhysicsImpostor): void;
  50067. wakeUpBody(impostor: PhysicsImpostor): void;
  50068. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50069. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50070. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50071. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50072. getRadius(impostor: PhysicsImpostor): number;
  50073. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50074. dispose(): void;
  50075. /**
  50076. * Does a raycast in the physics world
  50077. * @param from when should the ray start?
  50078. * @param to when should the ray end?
  50079. * @returns PhysicsRaycastResult
  50080. */
  50081. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50082. }
  50083. }
  50084. declare module BABYLON {
  50085. /**
  50086. * Class containing static functions to help procedurally build meshes
  50087. */
  50088. export class RibbonBuilder {
  50089. /**
  50090. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50091. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50092. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50093. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50094. * * 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
  50095. * * 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
  50096. * * 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
  50097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50098. * * 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
  50099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50100. * * 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
  50101. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50102. * * 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
  50103. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50105. * @param name defines the name of the mesh
  50106. * @param options defines the options used to create the mesh
  50107. * @param scene defines the hosting scene
  50108. * @returns the ribbon mesh
  50109. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50110. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50111. */
  50112. static CreateRibbon(name: string, options: {
  50113. pathArray: Vector3[][];
  50114. closeArray?: boolean;
  50115. closePath?: boolean;
  50116. offset?: number;
  50117. updatable?: boolean;
  50118. sideOrientation?: number;
  50119. frontUVs?: Vector4;
  50120. backUVs?: Vector4;
  50121. instance?: Mesh;
  50122. invertUV?: boolean;
  50123. uvs?: Vector2[];
  50124. colors?: Color4[];
  50125. }, scene?: Nullable<Scene>): Mesh;
  50126. }
  50127. }
  50128. declare module BABYLON {
  50129. /**
  50130. * Class containing static functions to help procedurally build meshes
  50131. */
  50132. export class ShapeBuilder {
  50133. /**
  50134. * 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.
  50135. * * 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.
  50136. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50137. * * 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.
  50138. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50139. * * 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
  50140. * * 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
  50141. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50143. * * 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
  50144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50146. * @param name defines the name of the mesh
  50147. * @param options defines the options used to create the mesh
  50148. * @param scene defines the hosting scene
  50149. * @returns the extruded shape mesh
  50150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50152. */
  50153. static ExtrudeShape(name: string, options: {
  50154. shape: Vector3[];
  50155. path: Vector3[];
  50156. scale?: number;
  50157. rotation?: number;
  50158. cap?: number;
  50159. updatable?: boolean;
  50160. sideOrientation?: number;
  50161. frontUVs?: Vector4;
  50162. backUVs?: Vector4;
  50163. instance?: Mesh;
  50164. invertUV?: boolean;
  50165. }, scene?: Nullable<Scene>): Mesh;
  50166. /**
  50167. * Creates an custom extruded shape mesh.
  50168. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50169. * * 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.
  50170. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50171. * * 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
  50172. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50173. * * 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
  50174. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50175. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50176. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50177. * * 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
  50178. * * 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
  50179. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50181. * * 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
  50182. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50184. * @param name defines the name of the mesh
  50185. * @param options defines the options used to create the mesh
  50186. * @param scene defines the hosting scene
  50187. * @returns the custom extruded shape mesh
  50188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50191. */
  50192. static ExtrudeShapeCustom(name: string, options: {
  50193. shape: Vector3[];
  50194. path: Vector3[];
  50195. scaleFunction?: any;
  50196. rotationFunction?: any;
  50197. ribbonCloseArray?: boolean;
  50198. ribbonClosePath?: boolean;
  50199. cap?: number;
  50200. updatable?: boolean;
  50201. sideOrientation?: number;
  50202. frontUVs?: Vector4;
  50203. backUVs?: Vector4;
  50204. instance?: Mesh;
  50205. invertUV?: boolean;
  50206. }, scene?: Nullable<Scene>): Mesh;
  50207. private static _ExtrudeShapeGeneric;
  50208. }
  50209. }
  50210. declare module BABYLON {
  50211. /**
  50212. * AmmoJS Physics plugin
  50213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50214. * @see https://github.com/kripken/ammo.js/
  50215. */
  50216. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50217. private _useDeltaForWorldStep;
  50218. /**
  50219. * Reference to the Ammo library
  50220. */
  50221. bjsAMMO: any;
  50222. /**
  50223. * Created ammoJS world which physics bodies are added to
  50224. */
  50225. world: any;
  50226. /**
  50227. * Name of the plugin
  50228. */
  50229. name: string;
  50230. private _timeStep;
  50231. private _fixedTimeStep;
  50232. private _maxSteps;
  50233. private _tmpQuaternion;
  50234. private _tmpAmmoTransform;
  50235. private _tmpAmmoQuaternion;
  50236. private _tmpAmmoConcreteContactResultCallback;
  50237. private _collisionConfiguration;
  50238. private _dispatcher;
  50239. private _overlappingPairCache;
  50240. private _solver;
  50241. private _softBodySolver;
  50242. private _tmpAmmoVectorA;
  50243. private _tmpAmmoVectorB;
  50244. private _tmpAmmoVectorC;
  50245. private _tmpAmmoVectorD;
  50246. private _tmpContactCallbackResult;
  50247. private _tmpAmmoVectorRCA;
  50248. private _tmpAmmoVectorRCB;
  50249. private _raycastResult;
  50250. private static readonly DISABLE_COLLISION_FLAG;
  50251. private static readonly KINEMATIC_FLAG;
  50252. private static readonly DISABLE_DEACTIVATION_FLAG;
  50253. /**
  50254. * Initializes the ammoJS plugin
  50255. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50256. * @param ammoInjection can be used to inject your own ammo reference
  50257. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50258. */
  50259. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50260. /**
  50261. * Sets the gravity of the physics world (m/(s^2))
  50262. * @param gravity Gravity to set
  50263. */
  50264. setGravity(gravity: Vector3): void;
  50265. /**
  50266. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50267. * @param timeStep timestep to use in seconds
  50268. */
  50269. setTimeStep(timeStep: number): void;
  50270. /**
  50271. * 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)
  50272. * @param fixedTimeStep fixedTimeStep to use in seconds
  50273. */
  50274. setFixedTimeStep(fixedTimeStep: number): void;
  50275. /**
  50276. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50277. * @param maxSteps the maximum number of steps by the physics engine per frame
  50278. */
  50279. setMaxSteps(maxSteps: number): void;
  50280. /**
  50281. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50282. * @returns the current timestep in seconds
  50283. */
  50284. getTimeStep(): number;
  50285. private _isImpostorInContact;
  50286. private _isImpostorPairInContact;
  50287. private _stepSimulation;
  50288. /**
  50289. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50290. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50291. * After the step the babylon meshes are set to the position of the physics imposters
  50292. * @param delta amount of time to step forward
  50293. * @param impostors array of imposters to update before/after the step
  50294. */
  50295. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50296. /**
  50297. * Update babylon mesh to match physics world object
  50298. * @param impostor imposter to match
  50299. */
  50300. private _afterSoftStep;
  50301. /**
  50302. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50303. * @param impostor imposter to match
  50304. */
  50305. private _ropeStep;
  50306. /**
  50307. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50308. * @param impostor imposter to match
  50309. */
  50310. private _softbodyOrClothStep;
  50311. private _tmpVector;
  50312. private _tmpMatrix;
  50313. /**
  50314. * Applies an impulse on the imposter
  50315. * @param impostor imposter to apply impulse to
  50316. * @param force amount of force to be applied to the imposter
  50317. * @param contactPoint the location to apply the impulse on the imposter
  50318. */
  50319. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50320. /**
  50321. * Applies a force on the imposter
  50322. * @param impostor imposter to apply force
  50323. * @param force amount of force to be applied to the imposter
  50324. * @param contactPoint the location to apply the force on the imposter
  50325. */
  50326. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50327. /**
  50328. * Creates a physics body using the plugin
  50329. * @param impostor the imposter to create the physics body on
  50330. */
  50331. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50332. /**
  50333. * Removes the physics body from the imposter and disposes of the body's memory
  50334. * @param impostor imposter to remove the physics body from
  50335. */
  50336. removePhysicsBody(impostor: PhysicsImpostor): void;
  50337. /**
  50338. * Generates a joint
  50339. * @param impostorJoint the imposter joint to create the joint with
  50340. */
  50341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50342. /**
  50343. * Removes a joint
  50344. * @param impostorJoint the imposter joint to remove the joint from
  50345. */
  50346. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50347. private _addMeshVerts;
  50348. /**
  50349. * Initialise the soft body vertices to match its object's (mesh) vertices
  50350. * Softbody vertices (nodes) are in world space and to match this
  50351. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50352. * @param impostor to create the softbody for
  50353. */
  50354. private _softVertexData;
  50355. /**
  50356. * Create an impostor's soft body
  50357. * @param impostor to create the softbody for
  50358. */
  50359. private _createSoftbody;
  50360. /**
  50361. * Create cloth for an impostor
  50362. * @param impostor to create the softbody for
  50363. */
  50364. private _createCloth;
  50365. /**
  50366. * Create rope for an impostor
  50367. * @param impostor to create the softbody for
  50368. */
  50369. private _createRope;
  50370. private _addHullVerts;
  50371. private _createShape;
  50372. /**
  50373. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50374. * @param impostor imposter containing the physics body and babylon object
  50375. */
  50376. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50377. /**
  50378. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50379. * @param impostor imposter containing the physics body and babylon object
  50380. * @param newPosition new position
  50381. * @param newRotation new rotation
  50382. */
  50383. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50384. /**
  50385. * If this plugin is supported
  50386. * @returns true if its supported
  50387. */
  50388. isSupported(): boolean;
  50389. /**
  50390. * Sets the linear velocity of the physics body
  50391. * @param impostor imposter to set the velocity on
  50392. * @param velocity velocity to set
  50393. */
  50394. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50395. /**
  50396. * Sets the angular velocity of the physics body
  50397. * @param impostor imposter to set the velocity on
  50398. * @param velocity velocity to set
  50399. */
  50400. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50401. /**
  50402. * gets the linear velocity
  50403. * @param impostor imposter to get linear velocity from
  50404. * @returns linear velocity
  50405. */
  50406. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50407. /**
  50408. * gets the angular velocity
  50409. * @param impostor imposter to get angular velocity from
  50410. * @returns angular velocity
  50411. */
  50412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50413. /**
  50414. * Sets the mass of physics body
  50415. * @param impostor imposter to set the mass on
  50416. * @param mass mass to set
  50417. */
  50418. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50419. /**
  50420. * Gets the mass of the physics body
  50421. * @param impostor imposter to get the mass from
  50422. * @returns mass
  50423. */
  50424. getBodyMass(impostor: PhysicsImpostor): number;
  50425. /**
  50426. * Gets friction of the impostor
  50427. * @param impostor impostor to get friction from
  50428. * @returns friction value
  50429. */
  50430. getBodyFriction(impostor: PhysicsImpostor): number;
  50431. /**
  50432. * Sets friction of the impostor
  50433. * @param impostor impostor to set friction on
  50434. * @param friction friction value
  50435. */
  50436. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50437. /**
  50438. * Gets restitution of the impostor
  50439. * @param impostor impostor to get restitution from
  50440. * @returns restitution value
  50441. */
  50442. getBodyRestitution(impostor: PhysicsImpostor): number;
  50443. /**
  50444. * Sets resitution of the impostor
  50445. * @param impostor impostor to set resitution on
  50446. * @param restitution resitution value
  50447. */
  50448. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50449. /**
  50450. * Gets pressure inside the impostor
  50451. * @param impostor impostor to get pressure from
  50452. * @returns pressure value
  50453. */
  50454. getBodyPressure(impostor: PhysicsImpostor): number;
  50455. /**
  50456. * Sets pressure inside a soft body impostor
  50457. * Cloth and rope must remain 0 pressure
  50458. * @param impostor impostor to set pressure on
  50459. * @param pressure pressure value
  50460. */
  50461. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50462. /**
  50463. * Gets stiffness of the impostor
  50464. * @param impostor impostor to get stiffness from
  50465. * @returns pressure value
  50466. */
  50467. getBodyStiffness(impostor: PhysicsImpostor): number;
  50468. /**
  50469. * Sets stiffness of the impostor
  50470. * @param impostor impostor to set stiffness on
  50471. * @param stiffness stiffness value from 0 to 1
  50472. */
  50473. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50474. /**
  50475. * Gets velocityIterations of the impostor
  50476. * @param impostor impostor to get velocity iterations from
  50477. * @returns velocityIterations value
  50478. */
  50479. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50480. /**
  50481. * Sets velocityIterations of the impostor
  50482. * @param impostor impostor to set velocity iterations on
  50483. * @param velocityIterations velocityIterations value
  50484. */
  50485. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50486. /**
  50487. * Gets positionIterations of the impostor
  50488. * @param impostor impostor to get position iterations from
  50489. * @returns positionIterations value
  50490. */
  50491. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50492. /**
  50493. * Sets positionIterations of the impostor
  50494. * @param impostor impostor to set position on
  50495. * @param positionIterations positionIterations value
  50496. */
  50497. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50498. /**
  50499. * Append an anchor to a cloth object
  50500. * @param impostor is the cloth impostor to add anchor to
  50501. * @param otherImpostor is the rigid impostor to anchor to
  50502. * @param width ratio across width from 0 to 1
  50503. * @param height ratio up height from 0 to 1
  50504. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50505. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50506. */
  50507. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50508. /**
  50509. * Append an hook to a rope object
  50510. * @param impostor is the rope impostor to add hook to
  50511. * @param otherImpostor is the rigid impostor to hook to
  50512. * @param length ratio along the rope from 0 to 1
  50513. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50514. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50515. */
  50516. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50517. /**
  50518. * Sleeps the physics body and stops it from being active
  50519. * @param impostor impostor to sleep
  50520. */
  50521. sleepBody(impostor: PhysicsImpostor): void;
  50522. /**
  50523. * Activates the physics body
  50524. * @param impostor impostor to activate
  50525. */
  50526. wakeUpBody(impostor: PhysicsImpostor): void;
  50527. /**
  50528. * Updates the distance parameters of the joint
  50529. * @param joint joint to update
  50530. * @param maxDistance maximum distance of the joint
  50531. * @param minDistance minimum distance of the joint
  50532. */
  50533. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50534. /**
  50535. * Sets a motor on the joint
  50536. * @param joint joint to set motor on
  50537. * @param speed speed of the motor
  50538. * @param maxForce maximum force of the motor
  50539. * @param motorIndex index of the motor
  50540. */
  50541. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50542. /**
  50543. * Sets the motors limit
  50544. * @param joint joint to set limit on
  50545. * @param upperLimit upper limit
  50546. * @param lowerLimit lower limit
  50547. */
  50548. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50549. /**
  50550. * Syncs the position and rotation of a mesh with the impostor
  50551. * @param mesh mesh to sync
  50552. * @param impostor impostor to update the mesh with
  50553. */
  50554. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50555. /**
  50556. * Gets the radius of the impostor
  50557. * @param impostor impostor to get radius from
  50558. * @returns the radius
  50559. */
  50560. getRadius(impostor: PhysicsImpostor): number;
  50561. /**
  50562. * Gets the box size of the impostor
  50563. * @param impostor impostor to get box size from
  50564. * @param result the resulting box size
  50565. */
  50566. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50567. /**
  50568. * Disposes of the impostor
  50569. */
  50570. dispose(): void;
  50571. /**
  50572. * Does a raycast in the physics world
  50573. * @param from when should the ray start?
  50574. * @param to when should the ray end?
  50575. * @returns PhysicsRaycastResult
  50576. */
  50577. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50578. }
  50579. }
  50580. declare module BABYLON {
  50581. interface AbstractScene {
  50582. /**
  50583. * The list of reflection probes added to the scene
  50584. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50585. */
  50586. reflectionProbes: Array<ReflectionProbe>;
  50587. /**
  50588. * Removes the given reflection probe from this scene.
  50589. * @param toRemove The reflection probe to remove
  50590. * @returns The index of the removed reflection probe
  50591. */
  50592. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50593. /**
  50594. * Adds the given reflection probe to this scene.
  50595. * @param newReflectionProbe The reflection probe to add
  50596. */
  50597. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50598. }
  50599. /**
  50600. * Class used to generate realtime reflection / refraction cube textures
  50601. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50602. */
  50603. export class ReflectionProbe {
  50604. /** defines the name of the probe */
  50605. name: string;
  50606. private _scene;
  50607. private _renderTargetTexture;
  50608. private _projectionMatrix;
  50609. private _viewMatrix;
  50610. private _target;
  50611. private _add;
  50612. private _attachedMesh;
  50613. private _invertYAxis;
  50614. /** Gets or sets probe position (center of the cube map) */
  50615. position: Vector3;
  50616. /**
  50617. * Creates a new reflection probe
  50618. * @param name defines the name of the probe
  50619. * @param size defines the texture resolution (for each face)
  50620. * @param scene defines the hosting scene
  50621. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50622. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50623. */
  50624. constructor(
  50625. /** defines the name of the probe */
  50626. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50627. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50628. samples: number;
  50629. /** Gets or sets the refresh rate to use (on every frame by default) */
  50630. refreshRate: number;
  50631. /**
  50632. * Gets the hosting scene
  50633. * @returns a Scene
  50634. */
  50635. getScene(): Scene;
  50636. /** Gets the internal CubeTexture used to render to */
  50637. readonly cubeTexture: RenderTargetTexture;
  50638. /** Gets the list of meshes to render */
  50639. readonly renderList: Nullable<AbstractMesh[]>;
  50640. /**
  50641. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50642. * @param mesh defines the mesh to attach to
  50643. */
  50644. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50645. /**
  50646. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50647. * @param renderingGroupId The rendering group id corresponding to its index
  50648. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50649. */
  50650. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50651. /**
  50652. * Clean all associated resources
  50653. */
  50654. dispose(): void;
  50655. /**
  50656. * Converts the reflection probe information to a readable string for debug purpose.
  50657. * @param fullDetails Supports for multiple levels of logging within scene loading
  50658. * @returns the human readable reflection probe info
  50659. */
  50660. toString(fullDetails?: boolean): string;
  50661. /**
  50662. * Get the class name of the relfection probe.
  50663. * @returns "ReflectionProbe"
  50664. */
  50665. getClassName(): string;
  50666. /**
  50667. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50668. * @returns The JSON representation of the texture
  50669. */
  50670. serialize(): any;
  50671. /**
  50672. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50673. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50674. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50675. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50676. * @returns The parsed reflection probe if successful
  50677. */
  50678. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50679. }
  50680. }
  50681. declare module BABYLON {
  50682. /** @hidden */
  50683. export var _BabylonLoaderRegistered: boolean;
  50684. }
  50685. declare module BABYLON {
  50686. /**
  50687. * The Physically based simple base material of BJS.
  50688. *
  50689. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50690. * It is used as the base class for both the specGloss and metalRough conventions.
  50691. */
  50692. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50693. /**
  50694. * Number of Simultaneous lights allowed on the material.
  50695. */
  50696. maxSimultaneousLights: number;
  50697. /**
  50698. * If sets to true, disables all the lights affecting the material.
  50699. */
  50700. disableLighting: boolean;
  50701. /**
  50702. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50703. */
  50704. environmentTexture: BaseTexture;
  50705. /**
  50706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50707. */
  50708. invertNormalMapX: boolean;
  50709. /**
  50710. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50711. */
  50712. invertNormalMapY: boolean;
  50713. /**
  50714. * Normal map used in the model.
  50715. */
  50716. normalTexture: BaseTexture;
  50717. /**
  50718. * Emissivie color used to self-illuminate the model.
  50719. */
  50720. emissiveColor: Color3;
  50721. /**
  50722. * Emissivie texture used to self-illuminate the model.
  50723. */
  50724. emissiveTexture: BaseTexture;
  50725. /**
  50726. * Occlusion Channel Strenght.
  50727. */
  50728. occlusionStrength: number;
  50729. /**
  50730. * Occlusion Texture of the material (adding extra occlusion effects).
  50731. */
  50732. occlusionTexture: BaseTexture;
  50733. /**
  50734. * Defines the alpha limits in alpha test mode.
  50735. */
  50736. alphaCutOff: number;
  50737. /**
  50738. * Gets the current double sided mode.
  50739. */
  50740. /**
  50741. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50742. */
  50743. doubleSided: boolean;
  50744. /**
  50745. * Stores the pre-calculated light information of a mesh in a texture.
  50746. */
  50747. lightmapTexture: BaseTexture;
  50748. /**
  50749. * If true, the light map contains occlusion information instead of lighting info.
  50750. */
  50751. useLightmapAsShadowmap: boolean;
  50752. /**
  50753. * Instantiates a new PBRMaterial instance.
  50754. *
  50755. * @param name The material name
  50756. * @param scene The scene the material will be use in.
  50757. */
  50758. constructor(name: string, scene: Scene);
  50759. getClassName(): string;
  50760. }
  50761. }
  50762. declare module BABYLON {
  50763. /**
  50764. * The PBR material of BJS following the metal roughness convention.
  50765. *
  50766. * This fits to the PBR convention in the GLTF definition:
  50767. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50768. */
  50769. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50770. /**
  50771. * The base color has two different interpretations depending on the value of metalness.
  50772. * When the material is a metal, the base color is the specific measured reflectance value
  50773. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50774. * of the material.
  50775. */
  50776. baseColor: Color3;
  50777. /**
  50778. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50779. * well as opacity information in the alpha channel.
  50780. */
  50781. baseTexture: BaseTexture;
  50782. /**
  50783. * Specifies the metallic scalar value of the material.
  50784. * Can also be used to scale the metalness values of the metallic texture.
  50785. */
  50786. metallic: number;
  50787. /**
  50788. * Specifies the roughness scalar value of the material.
  50789. * Can also be used to scale the roughness values of the metallic texture.
  50790. */
  50791. roughness: number;
  50792. /**
  50793. * Texture containing both the metallic value in the B channel and the
  50794. * roughness value in the G channel to keep better precision.
  50795. */
  50796. metallicRoughnessTexture: BaseTexture;
  50797. /**
  50798. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50799. *
  50800. * @param name The material name
  50801. * @param scene The scene the material will be use in.
  50802. */
  50803. constructor(name: string, scene: Scene);
  50804. /**
  50805. * Return the currrent class name of the material.
  50806. */
  50807. getClassName(): string;
  50808. /**
  50809. * Makes a duplicate of the current material.
  50810. * @param name - name to use for the new material.
  50811. */
  50812. clone(name: string): PBRMetallicRoughnessMaterial;
  50813. /**
  50814. * Serialize the material to a parsable JSON object.
  50815. */
  50816. serialize(): any;
  50817. /**
  50818. * Parses a JSON object correponding to the serialize function.
  50819. */
  50820. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50821. }
  50822. }
  50823. declare module BABYLON {
  50824. /**
  50825. * The PBR material of BJS following the specular glossiness convention.
  50826. *
  50827. * This fits to the PBR convention in the GLTF definition:
  50828. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50829. */
  50830. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50831. /**
  50832. * Specifies the diffuse color of the material.
  50833. */
  50834. diffuseColor: Color3;
  50835. /**
  50836. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50837. * channel.
  50838. */
  50839. diffuseTexture: BaseTexture;
  50840. /**
  50841. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50842. */
  50843. specularColor: Color3;
  50844. /**
  50845. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50846. */
  50847. glossiness: number;
  50848. /**
  50849. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50850. */
  50851. specularGlossinessTexture: BaseTexture;
  50852. /**
  50853. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50854. *
  50855. * @param name The material name
  50856. * @param scene The scene the material will be use in.
  50857. */
  50858. constructor(name: string, scene: Scene);
  50859. /**
  50860. * Return the currrent class name of the material.
  50861. */
  50862. getClassName(): string;
  50863. /**
  50864. * Makes a duplicate of the current material.
  50865. * @param name - name to use for the new material.
  50866. */
  50867. clone(name: string): PBRSpecularGlossinessMaterial;
  50868. /**
  50869. * Serialize the material to a parsable JSON object.
  50870. */
  50871. serialize(): any;
  50872. /**
  50873. * Parses a JSON object correponding to the serialize function.
  50874. */
  50875. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50876. }
  50877. }
  50878. declare module BABYLON {
  50879. /**
  50880. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50881. * It can help converting any input color in a desired output one. This can then be used to create effects
  50882. * from sepia, black and white to sixties or futuristic rendering...
  50883. *
  50884. * The only supported format is currently 3dl.
  50885. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50886. */
  50887. export class ColorGradingTexture extends BaseTexture {
  50888. /**
  50889. * The current texture matrix. (will always be identity in color grading texture)
  50890. */
  50891. private _textureMatrix;
  50892. /**
  50893. * The texture URL.
  50894. */
  50895. url: string;
  50896. /**
  50897. * Empty line regex stored for GC.
  50898. */
  50899. private static _noneEmptyLineRegex;
  50900. private _engine;
  50901. /**
  50902. * Instantiates a ColorGradingTexture from the following parameters.
  50903. *
  50904. * @param url The location of the color gradind data (currently only supporting 3dl)
  50905. * @param scene The scene the texture will be used in
  50906. */
  50907. constructor(url: string, scene: Scene);
  50908. /**
  50909. * Returns the texture matrix used in most of the material.
  50910. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50911. */
  50912. getTextureMatrix(): Matrix;
  50913. /**
  50914. * Occurs when the file being loaded is a .3dl LUT file.
  50915. */
  50916. private load3dlTexture;
  50917. /**
  50918. * Starts the loading process of the texture.
  50919. */
  50920. private loadTexture;
  50921. /**
  50922. * Clones the color gradind texture.
  50923. */
  50924. clone(): ColorGradingTexture;
  50925. /**
  50926. * Called during delayed load for textures.
  50927. */
  50928. delayLoad(): void;
  50929. /**
  50930. * Parses a color grading texture serialized by Babylon.
  50931. * @param parsedTexture The texture information being parsedTexture
  50932. * @param scene The scene to load the texture in
  50933. * @param rootUrl The root url of the data assets to load
  50934. * @return A color gradind texture
  50935. */
  50936. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50937. /**
  50938. * Serializes the LUT texture to json format.
  50939. */
  50940. serialize(): any;
  50941. }
  50942. }
  50943. declare module BABYLON {
  50944. /**
  50945. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50946. */
  50947. export class EquiRectangularCubeTexture extends BaseTexture {
  50948. /** The six faces of the cube. */
  50949. private static _FacesMapping;
  50950. private _noMipmap;
  50951. private _onLoad;
  50952. private _onError;
  50953. /** The size of the cubemap. */
  50954. private _size;
  50955. /** The buffer of the image. */
  50956. private _buffer;
  50957. /** The width of the input image. */
  50958. private _width;
  50959. /** The height of the input image. */
  50960. private _height;
  50961. /** The URL to the image. */
  50962. url: string;
  50963. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50964. coordinatesMode: number;
  50965. /**
  50966. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50967. * @param url The location of the image
  50968. * @param scene The scene the texture will be used in
  50969. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50970. * @param noMipmap Forces to not generate the mipmap if true
  50971. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50972. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50973. * @param onLoad — defines a callback called when texture is loaded
  50974. * @param onError — defines a callback called if there is an error
  50975. */
  50976. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50977. /**
  50978. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50979. */
  50980. private loadImage;
  50981. /**
  50982. * Convert the image buffer into a cubemap and create a CubeTexture.
  50983. */
  50984. private loadTexture;
  50985. /**
  50986. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50987. * @param buffer The ArrayBuffer that should be converted.
  50988. * @returns The buffer as Float32Array.
  50989. */
  50990. private getFloat32ArrayFromArrayBuffer;
  50991. /**
  50992. * Get the current class name of the texture useful for serialization or dynamic coding.
  50993. * @returns "EquiRectangularCubeTexture"
  50994. */
  50995. getClassName(): string;
  50996. /**
  50997. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50998. * @returns A clone of the current EquiRectangularCubeTexture.
  50999. */
  51000. clone(): EquiRectangularCubeTexture;
  51001. }
  51002. }
  51003. declare module BABYLON {
  51004. /**
  51005. * Based on jsTGALoader - Javascript loader for TGA file
  51006. * By Vincent Thibault
  51007. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51008. */
  51009. export class TGATools {
  51010. private static _TYPE_INDEXED;
  51011. private static _TYPE_RGB;
  51012. private static _TYPE_GREY;
  51013. private static _TYPE_RLE_INDEXED;
  51014. private static _TYPE_RLE_RGB;
  51015. private static _TYPE_RLE_GREY;
  51016. private static _ORIGIN_MASK;
  51017. private static _ORIGIN_SHIFT;
  51018. private static _ORIGIN_BL;
  51019. private static _ORIGIN_BR;
  51020. private static _ORIGIN_UL;
  51021. private static _ORIGIN_UR;
  51022. /**
  51023. * Gets the header of a TGA file
  51024. * @param data defines the TGA data
  51025. * @returns the header
  51026. */
  51027. static GetTGAHeader(data: Uint8Array): any;
  51028. /**
  51029. * Uploads TGA content to a Babylon Texture
  51030. * @hidden
  51031. */
  51032. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51033. /** @hidden */
  51034. 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;
  51035. /** @hidden */
  51036. 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;
  51037. /** @hidden */
  51038. 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;
  51039. /** @hidden */
  51040. 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;
  51041. /** @hidden */
  51042. 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;
  51043. /** @hidden */
  51044. 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;
  51045. }
  51046. }
  51047. declare module BABYLON {
  51048. /**
  51049. * Implementation of the TGA Texture Loader.
  51050. * @hidden
  51051. */
  51052. export class _TGATextureLoader implements IInternalTextureLoader {
  51053. /**
  51054. * Defines wether the loader supports cascade loading the different faces.
  51055. */
  51056. readonly supportCascades: boolean;
  51057. /**
  51058. * This returns if the loader support the current file information.
  51059. * @param extension defines the file extension of the file being loaded
  51060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51061. * @param fallback defines the fallback internal texture if any
  51062. * @param isBase64 defines whether the texture is encoded as a base64
  51063. * @param isBuffer defines whether the texture data are stored as a buffer
  51064. * @returns true if the loader can load the specified file
  51065. */
  51066. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51067. /**
  51068. * Transform the url before loading if required.
  51069. * @param rootUrl the url of the texture
  51070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51071. * @returns the transformed texture
  51072. */
  51073. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51074. /**
  51075. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51076. * @param rootUrl the url of the texture
  51077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51078. * @returns the fallback texture
  51079. */
  51080. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51081. /**
  51082. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51083. * @param data contains the texture data
  51084. * @param texture defines the BabylonJS internal texture
  51085. * @param createPolynomials will be true if polynomials have been requested
  51086. * @param onLoad defines the callback to trigger once the texture is ready
  51087. * @param onError defines the callback to trigger in case of error
  51088. */
  51089. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51090. /**
  51091. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51092. * @param data contains the texture data
  51093. * @param texture defines the BabylonJS internal texture
  51094. * @param callback defines the method to call once ready to upload
  51095. */
  51096. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51097. }
  51098. }
  51099. declare module BABYLON {
  51100. /**
  51101. * Info about the .basis files
  51102. */
  51103. class BasisFileInfo {
  51104. /**
  51105. * If the file has alpha
  51106. */
  51107. hasAlpha: boolean;
  51108. /**
  51109. * Info about each image of the basis file
  51110. */
  51111. images: Array<{
  51112. levels: Array<{
  51113. width: number;
  51114. height: number;
  51115. transcodedPixels: ArrayBufferView;
  51116. }>;
  51117. }>;
  51118. }
  51119. /**
  51120. * Result of transcoding a basis file
  51121. */
  51122. class TranscodeResult {
  51123. /**
  51124. * Info about the .basis file
  51125. */
  51126. fileInfo: BasisFileInfo;
  51127. /**
  51128. * Format to use when loading the file
  51129. */
  51130. format: number;
  51131. }
  51132. /**
  51133. * Configuration options for the Basis transcoder
  51134. */
  51135. export class BasisTranscodeConfiguration {
  51136. /**
  51137. * Supported compression formats used to determine the supported output format of the transcoder
  51138. */
  51139. supportedCompressionFormats?: {
  51140. /**
  51141. * etc1 compression format
  51142. */
  51143. etc1?: boolean;
  51144. /**
  51145. * s3tc compression format
  51146. */
  51147. s3tc?: boolean;
  51148. /**
  51149. * pvrtc compression format
  51150. */
  51151. pvrtc?: boolean;
  51152. /**
  51153. * etc2 compression format
  51154. */
  51155. etc2?: boolean;
  51156. };
  51157. /**
  51158. * If mipmap levels should be loaded for transcoded images (Default: true)
  51159. */
  51160. loadMipmapLevels?: boolean;
  51161. /**
  51162. * Index of a single image to load (Default: all images)
  51163. */
  51164. loadSingleImage?: number;
  51165. }
  51166. /**
  51167. * Used to load .Basis files
  51168. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51169. */
  51170. export class BasisTools {
  51171. private static _IgnoreSupportedFormats;
  51172. /**
  51173. * URL to use when loading the basis transcoder
  51174. */
  51175. static JSModuleURL: string;
  51176. /**
  51177. * URL to use when loading the wasm module for the transcoder
  51178. */
  51179. static WasmModuleURL: string;
  51180. /**
  51181. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51182. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51183. * @returns internal format corresponding to the Basis format
  51184. */
  51185. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51186. private static _WorkerPromise;
  51187. private static _Worker;
  51188. private static _actionId;
  51189. private static _CreateWorkerAsync;
  51190. /**
  51191. * Transcodes a loaded image file to compressed pixel data
  51192. * @param imageData image data to transcode
  51193. * @param config configuration options for the transcoding
  51194. * @returns a promise resulting in the transcoded image
  51195. */
  51196. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51197. /**
  51198. * Loads a texture from the transcode result
  51199. * @param texture texture load to
  51200. * @param transcodeResult the result of transcoding the basis file to load from
  51201. */
  51202. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51203. }
  51204. }
  51205. declare module BABYLON {
  51206. /**
  51207. * Loader for .basis file format
  51208. */
  51209. export class _BasisTextureLoader implements IInternalTextureLoader {
  51210. /**
  51211. * Defines whether the loader supports cascade loading the different faces.
  51212. */
  51213. readonly supportCascades: boolean;
  51214. /**
  51215. * This returns if the loader support the current file information.
  51216. * @param extension defines the file extension of the file being loaded
  51217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51218. * @param fallback defines the fallback internal texture if any
  51219. * @param isBase64 defines whether the texture is encoded as a base64
  51220. * @param isBuffer defines whether the texture data are stored as a buffer
  51221. * @returns true if the loader can load the specified file
  51222. */
  51223. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51224. /**
  51225. * Transform the url before loading if required.
  51226. * @param rootUrl the url of the texture
  51227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51228. * @returns the transformed texture
  51229. */
  51230. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51231. /**
  51232. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51233. * @param rootUrl the url of the texture
  51234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51235. * @returns the fallback texture
  51236. */
  51237. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51238. /**
  51239. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51240. * @param data contains the texture data
  51241. * @param texture defines the BabylonJS internal texture
  51242. * @param createPolynomials will be true if polynomials have been requested
  51243. * @param onLoad defines the callback to trigger once the texture is ready
  51244. * @param onError defines the callback to trigger in case of error
  51245. */
  51246. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51247. /**
  51248. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51249. * @param data contains the texture data
  51250. * @param texture defines the BabylonJS internal texture
  51251. * @param callback defines the method to call once ready to upload
  51252. */
  51253. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51254. }
  51255. }
  51256. declare module BABYLON {
  51257. /**
  51258. * 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.
  51259. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51260. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51261. */
  51262. export class CustomProceduralTexture extends ProceduralTexture {
  51263. private _animate;
  51264. private _time;
  51265. private _config;
  51266. private _texturePath;
  51267. /**
  51268. * Instantiates a new Custom Procedural Texture.
  51269. * 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.
  51270. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51271. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51272. * @param name Define the name of the texture
  51273. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51274. * @param size Define the size of the texture to create
  51275. * @param scene Define the scene the texture belongs to
  51276. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51277. * @param generateMipMaps Define if the texture should creates mip maps or not
  51278. */
  51279. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51280. private _loadJson;
  51281. /**
  51282. * Is the texture ready to be used ? (rendered at least once)
  51283. * @returns true if ready, otherwise, false.
  51284. */
  51285. isReady(): boolean;
  51286. /**
  51287. * Render the texture to its associated render target.
  51288. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51289. */
  51290. render(useCameraPostProcess?: boolean): void;
  51291. /**
  51292. * Update the list of dependant textures samplers in the shader.
  51293. */
  51294. updateTextures(): void;
  51295. /**
  51296. * Update the uniform values of the procedural texture in the shader.
  51297. */
  51298. updateShaderUniforms(): void;
  51299. /**
  51300. * Define if the texture animates or not.
  51301. */
  51302. animate: boolean;
  51303. }
  51304. }
  51305. declare module BABYLON {
  51306. /** @hidden */
  51307. export var noisePixelShader: {
  51308. name: string;
  51309. shader: string;
  51310. };
  51311. }
  51312. declare module BABYLON {
  51313. /**
  51314. * Class used to generate noise procedural textures
  51315. */
  51316. export class NoiseProceduralTexture extends ProceduralTexture {
  51317. private _time;
  51318. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51319. brightness: number;
  51320. /** Defines the number of octaves to process */
  51321. octaves: number;
  51322. /** Defines the level of persistence (0.8 by default) */
  51323. persistence: number;
  51324. /** Gets or sets animation speed factor (default is 1) */
  51325. animationSpeedFactor: number;
  51326. /**
  51327. * Creates a new NoiseProceduralTexture
  51328. * @param name defines the name fo the texture
  51329. * @param size defines the size of the texture (default is 256)
  51330. * @param scene defines the hosting scene
  51331. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51332. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51333. */
  51334. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51335. private _updateShaderUniforms;
  51336. protected _getDefines(): string;
  51337. /** Generate the current state of the procedural texture */
  51338. render(useCameraPostProcess?: boolean): void;
  51339. /**
  51340. * Serializes this noise procedural texture
  51341. * @returns a serialized noise procedural texture object
  51342. */
  51343. serialize(): any;
  51344. /**
  51345. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51346. * @param parsedTexture defines parsed texture data
  51347. * @param scene defines the current scene
  51348. * @param rootUrl defines the root URL containing noise procedural texture information
  51349. * @returns a parsed NoiseProceduralTexture
  51350. */
  51351. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51352. }
  51353. }
  51354. declare module BABYLON {
  51355. /**
  51356. * Raw cube texture where the raw buffers are passed in
  51357. */
  51358. export class RawCubeTexture extends CubeTexture {
  51359. /**
  51360. * Creates a cube texture where the raw buffers are passed in.
  51361. * @param scene defines the scene the texture is attached to
  51362. * @param data defines the array of data to use to create each face
  51363. * @param size defines the size of the textures
  51364. * @param format defines the format of the data
  51365. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51366. * @param generateMipMaps defines if the engine should generate the mip levels
  51367. * @param invertY defines if data must be stored with Y axis inverted
  51368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51369. * @param compression defines the compression used (null by default)
  51370. */
  51371. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51372. /**
  51373. * Updates the raw cube texture.
  51374. * @param data defines the data to store
  51375. * @param format defines the data format
  51376. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51377. * @param invertY defines if data must be stored with Y axis inverted
  51378. * @param compression defines the compression used (null by default)
  51379. * @param level defines which level of the texture to update
  51380. */
  51381. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51382. /**
  51383. * Updates a raw cube texture with RGBD encoded data.
  51384. * @param data defines the array of data [mipmap][face] to use to create each face
  51385. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51386. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51387. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51388. * @returns a promsie that resolves when the operation is complete
  51389. */
  51390. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51391. /**
  51392. * Clones the raw cube texture.
  51393. * @return a new cube texture
  51394. */
  51395. clone(): CubeTexture;
  51396. /** @hidden */
  51397. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51398. }
  51399. }
  51400. declare module BABYLON {
  51401. /**
  51402. * Class used to store 3D textures containing user data
  51403. */
  51404. export class RawTexture3D extends Texture {
  51405. /** Gets or sets the texture format to use */
  51406. format: number;
  51407. private _engine;
  51408. /**
  51409. * Create a new RawTexture3D
  51410. * @param data defines the data of the texture
  51411. * @param width defines the width of the texture
  51412. * @param height defines the height of the texture
  51413. * @param depth defines the depth of the texture
  51414. * @param format defines the texture format to use
  51415. * @param scene defines the hosting scene
  51416. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51417. * @param invertY defines if texture must be stored with Y axis inverted
  51418. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51419. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51420. */
  51421. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51422. /** Gets or sets the texture format to use */
  51423. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51424. /**
  51425. * Update the texture with new data
  51426. * @param data defines the data to store in the texture
  51427. */
  51428. update(data: ArrayBufferView): void;
  51429. }
  51430. }
  51431. declare module BABYLON {
  51432. /**
  51433. * Creates a refraction texture used by refraction channel of the standard material.
  51434. * It is like a mirror but to see through a material.
  51435. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51436. */
  51437. export class RefractionTexture extends RenderTargetTexture {
  51438. /**
  51439. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51440. * 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.
  51441. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51442. */
  51443. refractionPlane: Plane;
  51444. /**
  51445. * Define how deep under the surface we should see.
  51446. */
  51447. depth: number;
  51448. /**
  51449. * Creates a refraction texture used by refraction channel of the standard material.
  51450. * It is like a mirror but to see through a material.
  51451. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51452. * @param name Define the texture name
  51453. * @param size Define the size of the underlying texture
  51454. * @param scene Define the scene the refraction belongs to
  51455. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51456. */
  51457. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51458. /**
  51459. * Clone the refraction texture.
  51460. * @returns the cloned texture
  51461. */
  51462. clone(): RefractionTexture;
  51463. /**
  51464. * Serialize the texture to a JSON representation you could use in Parse later on
  51465. * @returns the serialized JSON representation
  51466. */
  51467. serialize(): any;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /**
  51472. * Defines the options related to the creation of an HtmlElementTexture
  51473. */
  51474. export interface IHtmlElementTextureOptions {
  51475. /**
  51476. * Defines wether mip maps should be created or not.
  51477. */
  51478. generateMipMaps?: boolean;
  51479. /**
  51480. * Defines the sampling mode of the texture.
  51481. */
  51482. samplingMode?: number;
  51483. /**
  51484. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51485. */
  51486. engine: Nullable<Engine>;
  51487. /**
  51488. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51489. */
  51490. scene: Nullable<Scene>;
  51491. }
  51492. /**
  51493. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51494. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51495. * is automatically managed.
  51496. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51497. * in your application.
  51498. *
  51499. * As the update is not automatic, you need to call them manually.
  51500. */
  51501. export class HtmlElementTexture extends BaseTexture {
  51502. /**
  51503. * The texture URL.
  51504. */
  51505. element: HTMLVideoElement | HTMLCanvasElement;
  51506. private static readonly DefaultOptions;
  51507. private _textureMatrix;
  51508. private _engine;
  51509. private _isVideo;
  51510. private _generateMipMaps;
  51511. private _samplingMode;
  51512. /**
  51513. * Instantiates a HtmlElementTexture from the following parameters.
  51514. *
  51515. * @param name Defines the name of the texture
  51516. * @param element Defines the video or canvas the texture is filled with
  51517. * @param options Defines the other none mandatory texture creation options
  51518. */
  51519. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51520. private _createInternalTexture;
  51521. /**
  51522. * Returns the texture matrix used in most of the material.
  51523. */
  51524. getTextureMatrix(): Matrix;
  51525. /**
  51526. * Updates the content of the texture.
  51527. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51528. */
  51529. update(invertY?: Nullable<boolean>): void;
  51530. }
  51531. }
  51532. declare module BABYLON {
  51533. /**
  51534. * Enum used to define the target of a block
  51535. */
  51536. export enum NodeMaterialBlockTargets {
  51537. /** Vertex shader */
  51538. Vertex = 1,
  51539. /** Fragment shader */
  51540. Fragment = 2,
  51541. /** Neutral */
  51542. Neutral = 4,
  51543. /** Vertex and Fragment */
  51544. VertexAndFragment = 3
  51545. }
  51546. }
  51547. declare module BABYLON {
  51548. /**
  51549. * Defines the kind of connection point for node based material
  51550. */
  51551. export enum NodeMaterialBlockConnectionPointTypes {
  51552. /** Float */
  51553. Float = 1,
  51554. /** Int */
  51555. Int = 2,
  51556. /** Vector2 */
  51557. Vector2 = 4,
  51558. /** Vector3 */
  51559. Vector3 = 8,
  51560. /** Vector4 */
  51561. Vector4 = 16,
  51562. /** Color3 */
  51563. Color3 = 32,
  51564. /** Color4 */
  51565. Color4 = 64,
  51566. /** Matrix */
  51567. Matrix = 128,
  51568. /** Detect type based on connection */
  51569. AutoDetect = 1024,
  51570. /** Output type that will be defined by input type */
  51571. BasedOnInput = 2048
  51572. }
  51573. }
  51574. declare module BABYLON {
  51575. /**
  51576. * Root class for all node material optimizers
  51577. */
  51578. export class NodeMaterialOptimizer {
  51579. /**
  51580. * Function used to optimize a NodeMaterial graph
  51581. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51582. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51583. */
  51584. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51585. }
  51586. }
  51587. declare module BABYLON {
  51588. /**
  51589. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51590. */
  51591. export class TransformBlock extends NodeMaterialBlock {
  51592. /**
  51593. * Defines the value to use to complement W value to transform it to a Vector4
  51594. */
  51595. complementW: number;
  51596. /**
  51597. * Defines the value to use to complement z value to transform it to a Vector4
  51598. */
  51599. complementZ: number;
  51600. /**
  51601. * Creates a new TransformBlock
  51602. * @param name defines the block name
  51603. */
  51604. constructor(name: string);
  51605. /**
  51606. * Gets the current class name
  51607. * @returns the class name
  51608. */
  51609. getClassName(): string;
  51610. /**
  51611. * Gets the vector input
  51612. */
  51613. readonly vector: NodeMaterialConnectionPoint;
  51614. /**
  51615. * Gets the output component
  51616. */
  51617. readonly output: NodeMaterialConnectionPoint;
  51618. /**
  51619. * Gets the matrix transform input
  51620. */
  51621. readonly transform: NodeMaterialConnectionPoint;
  51622. protected _buildBlock(state: NodeMaterialBuildState): this;
  51623. serialize(): any;
  51624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51625. }
  51626. }
  51627. declare module BABYLON {
  51628. /**
  51629. * Block used to output the vertex position
  51630. */
  51631. export class VertexOutputBlock extends NodeMaterialBlock {
  51632. /**
  51633. * Creates a new VertexOutputBlock
  51634. * @param name defines the block name
  51635. */
  51636. constructor(name: string);
  51637. /**
  51638. * Gets the current class name
  51639. * @returns the class name
  51640. */
  51641. getClassName(): string;
  51642. /**
  51643. * Gets the vector input component
  51644. */
  51645. readonly vector: NodeMaterialConnectionPoint;
  51646. protected _buildBlock(state: NodeMaterialBuildState): this;
  51647. }
  51648. }
  51649. declare module BABYLON {
  51650. /**
  51651. * Block used to output the final color
  51652. */
  51653. export class FragmentOutputBlock extends NodeMaterialBlock {
  51654. /**
  51655. * Create a new FragmentOutputBlock
  51656. * @param name defines the block name
  51657. */
  51658. constructor(name: string);
  51659. /**
  51660. * Gets the current class name
  51661. * @returns the class name
  51662. */
  51663. getClassName(): string;
  51664. /**
  51665. * Gets the rgba input component
  51666. */
  51667. readonly rgba: NodeMaterialConnectionPoint;
  51668. /**
  51669. * Gets the rgb input component
  51670. */
  51671. readonly rgb: NodeMaterialConnectionPoint;
  51672. /**
  51673. * Gets the a input component
  51674. */
  51675. readonly a: NodeMaterialConnectionPoint;
  51676. protected _buildBlock(state: NodeMaterialBuildState): this;
  51677. }
  51678. }
  51679. declare module BABYLON {
  51680. /**
  51681. * Interface used to configure the node material editor
  51682. */
  51683. export interface INodeMaterialEditorOptions {
  51684. /** Define the URl to load node editor script */
  51685. editorURL?: string;
  51686. }
  51687. /** @hidden */
  51688. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51689. /** BONES */
  51690. NUM_BONE_INFLUENCERS: number;
  51691. BonesPerMesh: number;
  51692. BONETEXTURE: boolean;
  51693. /** MORPH TARGETS */
  51694. MORPHTARGETS: boolean;
  51695. MORPHTARGETS_NORMAL: boolean;
  51696. MORPHTARGETS_TANGENT: boolean;
  51697. MORPHTARGETS_UV: boolean;
  51698. NUM_MORPH_INFLUENCERS: number;
  51699. /** IMAGE PROCESSING */
  51700. IMAGEPROCESSING: boolean;
  51701. VIGNETTE: boolean;
  51702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51703. VIGNETTEBLENDMODEOPAQUE: boolean;
  51704. TONEMAPPING: boolean;
  51705. TONEMAPPING_ACES: boolean;
  51706. CONTRAST: boolean;
  51707. EXPOSURE: boolean;
  51708. COLORCURVES: boolean;
  51709. COLORGRADING: boolean;
  51710. COLORGRADING3D: boolean;
  51711. SAMPLER3DGREENDEPTH: boolean;
  51712. SAMPLER3DBGRMAP: boolean;
  51713. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51714. constructor();
  51715. setValue(name: string, value: boolean): void;
  51716. }
  51717. /**
  51718. * Class used to configure NodeMaterial
  51719. */
  51720. export interface INodeMaterialOptions {
  51721. /**
  51722. * Defines if blocks should emit comments
  51723. */
  51724. emitComments: boolean;
  51725. }
  51726. /**
  51727. * Class used to create a node based material built by assembling shader blocks
  51728. */
  51729. export class NodeMaterial extends PushMaterial {
  51730. private static _BuildIdGenerator;
  51731. private _options;
  51732. private _vertexCompilationState;
  51733. private _fragmentCompilationState;
  51734. private _sharedData;
  51735. private _buildId;
  51736. private _buildWasSuccessful;
  51737. private _cachedWorldViewMatrix;
  51738. private _cachedWorldViewProjectionMatrix;
  51739. private _optimizers;
  51740. /** Define the URl to load node editor script */
  51741. static EditorURL: string;
  51742. private BJSNODEMATERIALEDITOR;
  51743. /** Get the inspector from bundle or global */
  51744. private _getGlobalNodeMaterialEditor;
  51745. /**
  51746. * 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)
  51747. */
  51748. ignoreAlpha: boolean;
  51749. /**
  51750. * Defines the maximum number of lights that can be used in the material
  51751. */
  51752. maxSimultaneousLights: number;
  51753. /**
  51754. * Observable raised when the material is built
  51755. */
  51756. onBuildObservable: Observable<NodeMaterial>;
  51757. /**
  51758. * Gets or sets the root nodes of the material vertex shader
  51759. */
  51760. _vertexOutputNodes: NodeMaterialBlock[];
  51761. /**
  51762. * Gets or sets the root nodes of the material fragment (pixel) shader
  51763. */
  51764. _fragmentOutputNodes: NodeMaterialBlock[];
  51765. /** Gets or sets options to control the node material overall behavior */
  51766. options: INodeMaterialOptions;
  51767. /**
  51768. * Default configuration related to image processing available in the standard Material.
  51769. */
  51770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51771. /**
  51772. * Gets the image processing configuration used either in this material.
  51773. */
  51774. /**
  51775. * Sets the Default image processing configuration used either in the this material.
  51776. *
  51777. * If sets to null, the scene one is in use.
  51778. */
  51779. imageProcessingConfiguration: ImageProcessingConfiguration;
  51780. /**
  51781. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51782. */
  51783. attachedBlocks: NodeMaterialBlock[];
  51784. /**
  51785. * Create a new node based material
  51786. * @param name defines the material name
  51787. * @param scene defines the hosting scene
  51788. * @param options defines creation option
  51789. */
  51790. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51791. /**
  51792. * Gets the current class name of the material e.g. "NodeMaterial"
  51793. * @returns the class name
  51794. */
  51795. getClassName(): string;
  51796. /**
  51797. * Keep track of the image processing observer to allow dispose and replace.
  51798. */
  51799. private _imageProcessingObserver;
  51800. /**
  51801. * Attaches a new image processing configuration to the Standard Material.
  51802. * @param configuration
  51803. */
  51804. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51805. /**
  51806. * Adds a new optimizer to the list of optimizers
  51807. * @param optimizer defines the optimizers to add
  51808. * @returns the current material
  51809. */
  51810. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51811. /**
  51812. * Remove an optimizer from the list of optimizers
  51813. * @param optimizer defines the optimizers to remove
  51814. * @returns the current material
  51815. */
  51816. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51817. /**
  51818. * Add a new block to the list of output nodes
  51819. * @param node defines the node to add
  51820. * @returns the current material
  51821. */
  51822. addOutputNode(node: NodeMaterialBlock): this;
  51823. /**
  51824. * Remove a block from the list of root nodes
  51825. * @param node defines the node to remove
  51826. * @returns the current material
  51827. */
  51828. removeOutputNode(node: NodeMaterialBlock): this;
  51829. private _addVertexOutputNode;
  51830. private _removeVertexOutputNode;
  51831. private _addFragmentOutputNode;
  51832. private _removeFragmentOutputNode;
  51833. /**
  51834. * Specifies if the material will require alpha blending
  51835. * @returns a boolean specifying if alpha blending is needed
  51836. */
  51837. needAlphaBlending(): boolean;
  51838. /**
  51839. * Specifies if this material should be rendered in alpha test mode
  51840. * @returns a boolean specifying if an alpha test is needed.
  51841. */
  51842. needAlphaTesting(): boolean;
  51843. private _initializeBlock;
  51844. private _resetDualBlocks;
  51845. /**
  51846. * Build the material and generates the inner effect
  51847. * @param verbose defines if the build should log activity
  51848. */
  51849. build(verbose?: boolean): void;
  51850. /**
  51851. * Runs an otpimization phase to try to improve the shader code
  51852. */
  51853. optimize(): void;
  51854. private _prepareDefinesForAttributes;
  51855. /**
  51856. * Get if the submesh is ready to be used and all its information available.
  51857. * Child classes can use it to update shaders
  51858. * @param mesh defines the mesh to check
  51859. * @param subMesh defines which submesh to check
  51860. * @param useInstances specifies that instances should be used
  51861. * @returns a boolean indicating that the submesh is ready or not
  51862. */
  51863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51864. /**
  51865. * Get a string representing the shaders built by the current node graph
  51866. */
  51867. readonly compiledShaders: string;
  51868. /**
  51869. * Binds the world matrix to the material
  51870. * @param world defines the world transformation matrix
  51871. */
  51872. bindOnlyWorldMatrix(world: Matrix): void;
  51873. /**
  51874. * Binds the submesh to this material by preparing the effect and shader to draw
  51875. * @param world defines the world transformation matrix
  51876. * @param mesh defines the mesh containing the submesh
  51877. * @param subMesh defines the submesh to bind the material to
  51878. */
  51879. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51880. /**
  51881. * Gets the active textures from the material
  51882. * @returns an array of textures
  51883. */
  51884. getActiveTextures(): BaseTexture[];
  51885. /**
  51886. * Specifies if the material uses a texture
  51887. * @param texture defines the texture to check against the material
  51888. * @returns a boolean specifying if the material uses the texture
  51889. */
  51890. hasTexture(texture: BaseTexture): boolean;
  51891. /**
  51892. * Disposes the material
  51893. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51894. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51895. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51896. */
  51897. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51898. /** Creates the node editor window. */
  51899. private _createNodeEditor;
  51900. /**
  51901. * Launch the node material editor
  51902. * @param config Define the configuration of the editor
  51903. * @return a promise fulfilled when the node editor is visible
  51904. */
  51905. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51906. /**
  51907. * Clear the current material
  51908. */
  51909. clear(): void;
  51910. /**
  51911. * Clear the current material and set it to a default state
  51912. */
  51913. setToDefault(): void;
  51914. private _gatherBlocks;
  51915. /**
  51916. * Serializes this material in a JSON representation
  51917. * @returns the serialized material object
  51918. */
  51919. serialize(): any;
  51920. /**
  51921. * Clear the current graph and load a new one from a serialization object
  51922. * @param source defines the JSON representation of the material
  51923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51924. */
  51925. loadFromSerialization(source: any, rootUrl?: string): void;
  51926. /**
  51927. * Creates a node material from parsed material data
  51928. * @param source defines the JSON representation of the material
  51929. * @param scene defines the hosting scene
  51930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51931. * @returns a new node material
  51932. */
  51933. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51934. }
  51935. }
  51936. declare module BABYLON {
  51937. /**
  51938. * Block used to read a texture from a sampler
  51939. */
  51940. export class TextureBlock extends NodeMaterialBlock {
  51941. private _defineName;
  51942. private _samplerName;
  51943. private _transformedUVName;
  51944. private _textureTransformName;
  51945. private _textureInfoName;
  51946. private _mainUVName;
  51947. private _mainUVDefineName;
  51948. /**
  51949. * Gets or sets the texture associated with the node
  51950. */
  51951. texture: Nullable<BaseTexture>;
  51952. /**
  51953. * Create a new TextureBlock
  51954. * @param name defines the block name
  51955. */
  51956. constructor(name: string);
  51957. /**
  51958. * Gets the current class name
  51959. * @returns the class name
  51960. */
  51961. getClassName(): string;
  51962. /**
  51963. * Gets the uv input component
  51964. */
  51965. readonly uv: NodeMaterialConnectionPoint;
  51966. /**
  51967. * Gets the output component
  51968. */
  51969. readonly output: NodeMaterialConnectionPoint;
  51970. autoConfigure(): void;
  51971. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51973. isReady(): boolean;
  51974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51975. private _injectVertexCode;
  51976. private _writeOutput;
  51977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51978. serialize(): any;
  51979. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51980. }
  51981. }
  51982. declare module BABYLON {
  51983. /**
  51984. * Class used to store shared data between 2 NodeMaterialBuildState
  51985. */
  51986. export class NodeMaterialBuildStateSharedData {
  51987. /**
  51988. * Gets the list of emitted varyings
  51989. */
  51990. varyings: string[];
  51991. /**
  51992. * Gets the varying declaration string
  51993. */
  51994. varyingDeclaration: string;
  51995. /**
  51996. * Input blocks
  51997. */
  51998. inputBlocks: InputBlock[];
  51999. /**
  52000. * Input blocks
  52001. */
  52002. textureBlocks: TextureBlock[];
  52003. /**
  52004. * Bindable blocks (Blocks that need to set data to the effect)
  52005. */
  52006. bindableBlocks: NodeMaterialBlock[];
  52007. /**
  52008. * List of blocks that can provide a compilation fallback
  52009. */
  52010. blocksWithFallbacks: NodeMaterialBlock[];
  52011. /**
  52012. * List of blocks that can provide a define update
  52013. */
  52014. blocksWithDefines: NodeMaterialBlock[];
  52015. /**
  52016. * List of blocks that can provide a repeatable content
  52017. */
  52018. repeatableContentBlocks: NodeMaterialBlock[];
  52019. /**
  52020. * List of blocks that can provide a dynamic list of uniforms
  52021. */
  52022. dynamicUniformBlocks: NodeMaterialBlock[];
  52023. /**
  52024. * List of blocks that can block the isReady function for the material
  52025. */
  52026. blockingBlocks: NodeMaterialBlock[];
  52027. /**
  52028. * Build Id used to avoid multiple recompilations
  52029. */
  52030. buildId: number;
  52031. /** List of emitted variables */
  52032. variableNames: {
  52033. [key: string]: number;
  52034. };
  52035. /** List of emitted defines */
  52036. defineNames: {
  52037. [key: string]: number;
  52038. };
  52039. /** Should emit comments? */
  52040. emitComments: boolean;
  52041. /** Emit build activity */
  52042. verbose: boolean;
  52043. /**
  52044. * Gets the compilation hints emitted at compilation time
  52045. */
  52046. hints: {
  52047. needWorldViewMatrix: boolean;
  52048. needWorldViewProjectionMatrix: boolean;
  52049. needAlphaBlending: boolean;
  52050. needAlphaTesting: boolean;
  52051. };
  52052. /**
  52053. * List of compilation checks
  52054. */
  52055. checks: {
  52056. emitVertex: boolean;
  52057. emitFragment: boolean;
  52058. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52059. };
  52060. /** Creates a new shared data */
  52061. constructor();
  52062. /**
  52063. * Emits console errors and exceptions if there is a failing check
  52064. */
  52065. emitErrors(): void;
  52066. }
  52067. }
  52068. declare module BABYLON {
  52069. /**
  52070. * Class used to store node based material build state
  52071. */
  52072. export class NodeMaterialBuildState {
  52073. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52074. supportUniformBuffers: boolean;
  52075. /**
  52076. * Gets the list of emitted attributes
  52077. */
  52078. attributes: string[];
  52079. /**
  52080. * Gets the list of emitted uniforms
  52081. */
  52082. uniforms: string[];
  52083. /**
  52084. * Gets the list of emitted uniform buffers
  52085. */
  52086. uniformBuffers: string[];
  52087. /**
  52088. * Gets the list of emitted samplers
  52089. */
  52090. samplers: string[];
  52091. /**
  52092. * Gets the list of emitted functions
  52093. */
  52094. functions: {
  52095. [key: string]: string;
  52096. };
  52097. /**
  52098. * Gets the target of the compilation state
  52099. */
  52100. target: NodeMaterialBlockTargets;
  52101. /**
  52102. * Gets the list of emitted counters
  52103. */
  52104. counters: {
  52105. [key: string]: number;
  52106. };
  52107. /**
  52108. * Shared data between multiple NodeMaterialBuildState instances
  52109. */
  52110. sharedData: NodeMaterialBuildStateSharedData;
  52111. /** @hidden */
  52112. _vertexState: NodeMaterialBuildState;
  52113. /** @hidden */
  52114. _attributeDeclaration: string;
  52115. /** @hidden */
  52116. _uniformDeclaration: string;
  52117. /** @hidden */
  52118. _samplerDeclaration: string;
  52119. /** @hidden */
  52120. _varyingTransfer: string;
  52121. private _repeatableContentAnchorIndex;
  52122. /** @hidden */
  52123. _builtCompilationString: string;
  52124. /**
  52125. * Gets the emitted compilation strings
  52126. */
  52127. compilationString: string;
  52128. /**
  52129. * Finalize the compilation strings
  52130. * @param state defines the current compilation state
  52131. */
  52132. finalize(state: NodeMaterialBuildState): void;
  52133. /** @hidden */
  52134. readonly _repeatableContentAnchor: string;
  52135. /** @hidden */
  52136. _getFreeVariableName(prefix: string): string;
  52137. /** @hidden */
  52138. _getFreeDefineName(prefix: string): string;
  52139. /** @hidden */
  52140. _excludeVariableName(name: string): void;
  52141. /** @hidden */
  52142. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52143. /** @hidden */
  52144. _emitFunction(name: string, code: string, comments: string): void;
  52145. /** @hidden */
  52146. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52147. replaceStrings?: {
  52148. search: RegExp;
  52149. replace: string;
  52150. }[];
  52151. repeatKey?: string;
  52152. }): string;
  52153. /** @hidden */
  52154. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52155. repeatKey?: string;
  52156. removeAttributes?: boolean;
  52157. removeUniforms?: boolean;
  52158. removeVaryings?: boolean;
  52159. removeIfDef?: boolean;
  52160. replaceStrings?: {
  52161. search: RegExp;
  52162. replace: string;
  52163. }[];
  52164. }, storeKey?: string): void;
  52165. /** @hidden */
  52166. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52167. /** @hidden */
  52168. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52169. }
  52170. }
  52171. declare module BABYLON {
  52172. /**
  52173. * Defines a block that can be used inside a node based material
  52174. */
  52175. export class NodeMaterialBlock {
  52176. private _buildId;
  52177. private _buildTarget;
  52178. private _target;
  52179. private _isFinalMerger;
  52180. private _isInput;
  52181. /** @hidden */
  52182. _inputs: NodeMaterialConnectionPoint[];
  52183. /** @hidden */
  52184. _outputs: NodeMaterialConnectionPoint[];
  52185. /**
  52186. * Gets or sets the name of the block
  52187. */
  52188. name: string;
  52189. /**
  52190. * Gets or sets the unique id of the node
  52191. */
  52192. uniqueId: number;
  52193. /**
  52194. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52195. */
  52196. readonly isFinalMerger: boolean;
  52197. /**
  52198. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52199. */
  52200. readonly isInput: boolean;
  52201. /**
  52202. * Gets or sets the build Id
  52203. */
  52204. buildId: number;
  52205. /**
  52206. * Gets or sets the target of the block
  52207. */
  52208. target: NodeMaterialBlockTargets;
  52209. /**
  52210. * Gets the list of input points
  52211. */
  52212. readonly inputs: NodeMaterialConnectionPoint[];
  52213. /** Gets the list of output points */
  52214. readonly outputs: NodeMaterialConnectionPoint[];
  52215. /**
  52216. * Find an input by its name
  52217. * @param name defines the name of the input to look for
  52218. * @returns the input or null if not found
  52219. */
  52220. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52221. /**
  52222. * Find an output by its name
  52223. * @param name defines the name of the outputto look for
  52224. * @returns the output or null if not found
  52225. */
  52226. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52227. /**
  52228. * Creates a new NodeMaterialBlock
  52229. * @param name defines the block name
  52230. * @param target defines the target of that block (Vertex by default)
  52231. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52232. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52233. */
  52234. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52235. /**
  52236. * Initialize the block and prepare the context for build
  52237. * @param state defines the state that will be used for the build
  52238. */
  52239. initialize(state: NodeMaterialBuildState): void;
  52240. /**
  52241. * Bind data to effect. Will only be called for blocks with isBindable === true
  52242. * @param effect defines the effect to bind data to
  52243. * @param nodeMaterial defines the hosting NodeMaterial
  52244. * @param mesh defines the mesh that will be rendered
  52245. */
  52246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52247. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52248. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52249. protected _writeFloat(value: number): string;
  52250. /**
  52251. * Gets the current class name e.g. "NodeMaterialBlock"
  52252. * @returns the class name
  52253. */
  52254. getClassName(): string;
  52255. /**
  52256. * Register a new input. Must be called inside a block constructor
  52257. * @param name defines the connection point name
  52258. * @param type defines the connection point type
  52259. * @param isOptional defines a boolean indicating that this input can be omitted
  52260. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52261. * @returns the current block
  52262. */
  52263. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52264. /**
  52265. * Register a new output. Must be called inside a block constructor
  52266. * @param name defines the connection point name
  52267. * @param type defines the connection point type
  52268. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52269. * @returns the current block
  52270. */
  52271. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52272. /**
  52273. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52274. * @param forOutput defines an optional connection point to check compatibility with
  52275. * @returns the first available input or null
  52276. */
  52277. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52278. /**
  52279. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52280. * @param forBlock defines an optional block to check compatibility with
  52281. * @returns the first available input or null
  52282. */
  52283. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52284. /**
  52285. * Connect current block with another block
  52286. * @param other defines the block to connect with
  52287. * @param options define the various options to help pick the right connections
  52288. * @returns the current block
  52289. */
  52290. connectTo(other: NodeMaterialBlock, options?: {
  52291. input?: string;
  52292. output?: string;
  52293. outputSwizzle?: string;
  52294. }): this | undefined;
  52295. protected _buildBlock(state: NodeMaterialBuildState): void;
  52296. /**
  52297. * Add uniforms, samplers and uniform buffers at compilation time
  52298. * @param state defines the state to update
  52299. * @param nodeMaterial defines the node material requesting the update
  52300. * @param defines defines the material defines to update
  52301. */
  52302. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52303. /**
  52304. * Add potential fallbacks if shader compilation fails
  52305. * @param mesh defines the mesh to be rendered
  52306. * @param fallbacks defines the current prioritized list of fallbacks
  52307. */
  52308. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52309. /**
  52310. * Update defines for shader compilation
  52311. * @param mesh defines the mesh to be rendered
  52312. * @param nodeMaterial defines the node material requesting the update
  52313. * @param defines defines the material defines to update
  52314. * @param useInstances specifies that instances should be used
  52315. */
  52316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52317. /**
  52318. * Initialize defines for shader compilation
  52319. * @param mesh defines the mesh to be rendered
  52320. * @param nodeMaterial defines the node material requesting the update
  52321. * @param defines defines the material defines to be prepared
  52322. * @param useInstances specifies that instances should be used
  52323. */
  52324. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52325. /**
  52326. * Lets the block try to connect some inputs automatically
  52327. */
  52328. autoConfigure(): void;
  52329. /**
  52330. * Function called when a block is declared as repeatable content generator
  52331. * @param vertexShaderState defines the current compilation state for the vertex shader
  52332. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52333. * @param mesh defines the mesh to be rendered
  52334. * @param defines defines the material defines to update
  52335. */
  52336. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52337. /**
  52338. * Checks if the block is ready
  52339. * @param mesh defines the mesh to be rendered
  52340. * @param nodeMaterial defines the node material requesting the update
  52341. * @param defines defines the material defines to update
  52342. * @param useInstances specifies that instances should be used
  52343. * @returns true if the block is ready
  52344. */
  52345. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52346. private _processBuild;
  52347. /**
  52348. * Compile the current node and generate the shader code
  52349. * @param state defines the current compilation state (uniforms, samplers, current string)
  52350. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  52351. * @returns true if already built
  52352. */
  52353. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  52354. /**
  52355. * Serializes this block in a JSON representation
  52356. * @returns the serialized block object
  52357. */
  52358. serialize(): any;
  52359. /** @hidden */
  52360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52361. }
  52362. }
  52363. declare module BABYLON {
  52364. /**
  52365. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52366. */
  52367. export enum NodeMaterialBlockConnectionPointMode {
  52368. /** Value is an uniform */
  52369. Uniform = 0,
  52370. /** Value is a mesh attribute */
  52371. Attribute = 1,
  52372. /** Value is a varying between vertex and fragment shaders */
  52373. Varying = 2,
  52374. /** Mode is undefined */
  52375. Undefined = 3
  52376. }
  52377. }
  52378. declare module BABYLON {
  52379. /**
  52380. * Enum used to define well known values e.g. values automatically provided by the system
  52381. */
  52382. export enum NodeMaterialWellKnownValues {
  52383. /** World */
  52384. World = 1,
  52385. /** View */
  52386. View = 2,
  52387. /** Projection */
  52388. Projection = 3,
  52389. /** ViewProjection */
  52390. ViewProjection = 4,
  52391. /** WorldView */
  52392. WorldView = 5,
  52393. /** WorldViewProjection */
  52394. WorldViewProjection = 6,
  52395. /** CameraPosition */
  52396. CameraPosition = 7,
  52397. /** Fog Color */
  52398. FogColor = 8
  52399. }
  52400. }
  52401. declare module BABYLON {
  52402. /**
  52403. * Block used to expose an input value
  52404. */
  52405. export class InputBlock extends NodeMaterialBlock {
  52406. private _mode;
  52407. private _associatedVariableName;
  52408. private _storedValue;
  52409. private _valueCallback;
  52410. private _type;
  52411. /** @hidden */
  52412. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52413. /**
  52414. * Gets or sets the connection point type (default is float)
  52415. */
  52416. readonly type: NodeMaterialBlockConnectionPointTypes;
  52417. /**
  52418. * Creates a new InputBlock
  52419. * @param name defines the block name
  52420. * @param target defines the target of that block (Vertex by default)
  52421. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52422. */
  52423. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52424. /**
  52425. * Gets the output component
  52426. */
  52427. readonly output: NodeMaterialConnectionPoint;
  52428. /**
  52429. * Set the source of this connection point to a vertex attribute
  52430. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52431. * @returns the current connection point
  52432. */
  52433. setAsAttribute(attributeName?: string): InputBlock;
  52434. /**
  52435. * Set the source of this connection point to a well known value
  52436. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52437. * @returns the current connection point
  52438. */
  52439. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52440. /**
  52441. * Gets or sets the value of that point.
  52442. * Please note that this value will be ignored if valueCallback is defined
  52443. */
  52444. value: any;
  52445. /**
  52446. * Gets or sets a callback used to get the value of that point.
  52447. * Please note that setting this value will force the connection point to ignore the value property
  52448. */
  52449. valueCallback: () => any;
  52450. /**
  52451. * Gets or sets the associated variable name in the shader
  52452. */
  52453. associatedVariableName: string;
  52454. /**
  52455. * Gets a boolean indicating that this connection point not defined yet
  52456. */
  52457. readonly isUndefined: boolean;
  52458. /**
  52459. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52460. * In this case the connection point name must be the name of the uniform to use.
  52461. * Can only be set on inputs
  52462. */
  52463. isUniform: boolean;
  52464. /**
  52465. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52466. * In this case the connection point name must be the name of the attribute to use
  52467. * Can only be set on inputs
  52468. */
  52469. isAttribute: boolean;
  52470. /**
  52471. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52472. * Can only be set on exit points
  52473. */
  52474. isVarying: boolean;
  52475. /**
  52476. * Gets a boolean indicating that the current connection point is a well known value
  52477. */
  52478. readonly isWellKnownValue: boolean;
  52479. /**
  52480. * Gets or sets the current well known value or null if not defined as well know value
  52481. */
  52482. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52483. /**
  52484. * Gets the current class name
  52485. * @returns the class name
  52486. */
  52487. getClassName(): string;
  52488. private _emitDefine;
  52489. /**
  52490. * Set the input block to its default value (based on its type)
  52491. */
  52492. setDefaultValue(): void;
  52493. private _emit;
  52494. /** @hidden */
  52495. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52496. /** @hidden */
  52497. _transmit(effect: Effect, scene: Scene): void;
  52498. protected _buildBlock(state: NodeMaterialBuildState): void;
  52499. serialize(): any;
  52500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52501. }
  52502. }
  52503. declare module BABYLON {
  52504. /**
  52505. * Defines a connection point for a block
  52506. */
  52507. export class NodeMaterialConnectionPoint {
  52508. /** @hidden */
  52509. _ownerBlock: NodeMaterialBlock;
  52510. /** @hidden */
  52511. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52512. private _endpoints;
  52513. private _associatedVariableName;
  52514. /** @hidden */
  52515. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52516. private _type;
  52517. /** @hidden */
  52518. _enforceAssociatedVariableName: boolean;
  52519. /**
  52520. * Gets or sets the additional types supported byt this connection point
  52521. */
  52522. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52523. /**
  52524. * Gets or sets the associated variable name in the shader
  52525. */
  52526. associatedVariableName: string;
  52527. /**
  52528. * Gets or sets the connection point type (default is float)
  52529. */
  52530. type: NodeMaterialBlockConnectionPointTypes;
  52531. /**
  52532. * Gets or sets the connection point name
  52533. */
  52534. name: string;
  52535. /**
  52536. * Gets or sets a boolean indicating that this connection point can be omitted
  52537. */
  52538. isOptional: boolean;
  52539. /**
  52540. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52541. */
  52542. define: string;
  52543. /** Gets or sets the target of that connection point */
  52544. target: NodeMaterialBlockTargets;
  52545. /**
  52546. * Gets a boolean indicating that the current point is connected
  52547. */
  52548. readonly isConnected: boolean;
  52549. /**
  52550. * Gets a boolean indicating that the current point is connected to an input block
  52551. */
  52552. readonly isConnectedToInput: boolean;
  52553. /**
  52554. * Gets a the connected input block (if any)
  52555. */
  52556. readonly connectInputBlock: Nullable<InputBlock>;
  52557. /** Get the other side of the connection (if any) */
  52558. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52559. /** Get the block that owns this connection point */
  52560. readonly ownerBlock: NodeMaterialBlock;
  52561. /** Get the block connected on the other side of this connection (if any) */
  52562. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52563. /** Get the block connected on the endpoints of this connection (if any) */
  52564. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52565. /** Gets the list of connected endpoints */
  52566. readonly endpoints: NodeMaterialConnectionPoint[];
  52567. /**
  52568. * Creates a new connection point
  52569. * @param name defines the connection point name
  52570. * @param ownerBlock defines the block hosting this connection point
  52571. */
  52572. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52573. /**
  52574. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52575. * @returns the class name
  52576. */
  52577. getClassName(): string;
  52578. /**
  52579. * Gets an boolean indicating if the current point can be connected to another point
  52580. * @param connectionPoint defines the other connection point
  52581. * @returns true if the connection is possible
  52582. */
  52583. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52584. /**
  52585. * Connect this point to another connection point
  52586. * @param connectionPoint defines the other connection point
  52587. * @returns the current connection point
  52588. */
  52589. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52590. /**
  52591. * Disconnect this point from one of his endpoint
  52592. * @param endpoint defines the other connection point
  52593. * @returns the current connection point
  52594. */
  52595. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52596. /**
  52597. * Serializes this point in a JSON representation
  52598. * @returns the serialized point object
  52599. */
  52600. serialize(): any;
  52601. }
  52602. }
  52603. declare module BABYLON {
  52604. /**
  52605. * Block used to add support for vertex skinning (bones)
  52606. */
  52607. export class BonesBlock extends NodeMaterialBlock {
  52608. /**
  52609. * Creates a new BonesBlock
  52610. * @param name defines the block name
  52611. */
  52612. constructor(name: string);
  52613. /**
  52614. * Initialize the block and prepare the context for build
  52615. * @param state defines the state that will be used for the build
  52616. */
  52617. initialize(state: NodeMaterialBuildState): void;
  52618. /**
  52619. * Gets the current class name
  52620. * @returns the class name
  52621. */
  52622. getClassName(): string;
  52623. /**
  52624. * Gets the matrix indices input component
  52625. */
  52626. readonly matricesIndices: NodeMaterialConnectionPoint;
  52627. /**
  52628. * Gets the matrix weights input component
  52629. */
  52630. readonly matricesWeights: NodeMaterialConnectionPoint;
  52631. /**
  52632. * Gets the extra matrix indices input component
  52633. */
  52634. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52635. /**
  52636. * Gets the extra matrix weights input component
  52637. */
  52638. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52639. /**
  52640. * Gets the world input component
  52641. */
  52642. readonly world: NodeMaterialConnectionPoint;
  52643. /**
  52644. * Gets the output component
  52645. */
  52646. readonly output: NodeMaterialConnectionPoint;
  52647. autoConfigure(): void;
  52648. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52649. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52651. protected _buildBlock(state: NodeMaterialBuildState): this;
  52652. }
  52653. }
  52654. declare module BABYLON {
  52655. /**
  52656. * Block used to add support for instances
  52657. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52658. */
  52659. export class InstancesBlock extends NodeMaterialBlock {
  52660. /**
  52661. * Creates a new InstancesBlock
  52662. * @param name defines the block name
  52663. */
  52664. constructor(name: string);
  52665. /**
  52666. * Gets the current class name
  52667. * @returns the class name
  52668. */
  52669. getClassName(): string;
  52670. /**
  52671. * Gets the first world row input component
  52672. */
  52673. readonly world0: NodeMaterialConnectionPoint;
  52674. /**
  52675. * Gets the second world row input component
  52676. */
  52677. readonly world1: NodeMaterialConnectionPoint;
  52678. /**
  52679. * Gets the third world row input component
  52680. */
  52681. readonly world2: NodeMaterialConnectionPoint;
  52682. /**
  52683. * Gets the forth world row input component
  52684. */
  52685. readonly world3: NodeMaterialConnectionPoint;
  52686. /**
  52687. * Gets the world input component
  52688. */
  52689. readonly world: NodeMaterialConnectionPoint;
  52690. /**
  52691. * Gets the output component
  52692. */
  52693. readonly output: NodeMaterialConnectionPoint;
  52694. autoConfigure(): void;
  52695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52696. protected _buildBlock(state: NodeMaterialBuildState): this;
  52697. }
  52698. }
  52699. declare module BABYLON {
  52700. /**
  52701. * Block used to add morph targets support to vertex shader
  52702. */
  52703. export class MorphTargetsBlock extends NodeMaterialBlock {
  52704. private _repeatableContentAnchor;
  52705. private _repeatebleContentGenerated;
  52706. /**
  52707. * Create a new MorphTargetsBlock
  52708. * @param name defines the block name
  52709. */
  52710. constructor(name: string);
  52711. /**
  52712. * Gets the current class name
  52713. * @returns the class name
  52714. */
  52715. getClassName(): string;
  52716. /**
  52717. * Gets the position input component
  52718. */
  52719. readonly position: NodeMaterialConnectionPoint;
  52720. /**
  52721. * Gets the normal input component
  52722. */
  52723. readonly normal: NodeMaterialConnectionPoint;
  52724. /**
  52725. * Gets the tangent input component
  52726. */
  52727. readonly tangent: NodeMaterialConnectionPoint;
  52728. /**
  52729. * Gets the tangent input component
  52730. */
  52731. readonly uv: NodeMaterialConnectionPoint;
  52732. /**
  52733. * Gets the position output component
  52734. */
  52735. readonly positionOutput: NodeMaterialConnectionPoint;
  52736. /**
  52737. * Gets the normal output component
  52738. */
  52739. readonly normalOutput: NodeMaterialConnectionPoint;
  52740. /**
  52741. * Gets the tangent output component
  52742. */
  52743. readonly tangentOutput: NodeMaterialConnectionPoint;
  52744. /**
  52745. * Gets the tangent output component
  52746. */
  52747. readonly uvOutput: NodeMaterialConnectionPoint;
  52748. initialize(state: NodeMaterialBuildState): void;
  52749. autoConfigure(): void;
  52750. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52751. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52752. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52753. protected _buildBlock(state: NodeMaterialBuildState): this;
  52754. }
  52755. }
  52756. declare module BABYLON {
  52757. /**
  52758. * Block used to add an alpha test in the fragment shader
  52759. */
  52760. export class AlphaTestBlock extends NodeMaterialBlock {
  52761. /**
  52762. * Gets or sets the alpha value where alpha testing happens
  52763. */
  52764. alphaCutOff: number;
  52765. /**
  52766. * Create a new AlphaTestBlock
  52767. * @param name defines the block name
  52768. */
  52769. constructor(name: string);
  52770. /**
  52771. * Gets the current class name
  52772. * @returns the class name
  52773. */
  52774. getClassName(): string;
  52775. /**
  52776. * Gets the color input component
  52777. */
  52778. readonly color: NodeMaterialConnectionPoint;
  52779. /**
  52780. * Gets the alpha input component
  52781. */
  52782. readonly alpha: NodeMaterialConnectionPoint;
  52783. protected _buildBlock(state: NodeMaterialBuildState): this;
  52784. }
  52785. }
  52786. declare module BABYLON {
  52787. /**
  52788. * Block used to create a Color3/4 out of individual inputs (one for each component)
  52789. */
  52790. export class ColorMergerBlock extends NodeMaterialBlock {
  52791. /**
  52792. * Create a new ColorMergerBlock
  52793. * @param name defines the block name
  52794. */
  52795. constructor(name: string);
  52796. /**
  52797. * Gets the current class name
  52798. * @returns the class name
  52799. */
  52800. getClassName(): string;
  52801. /**
  52802. * Gets the r component (input)
  52803. */
  52804. readonly r: NodeMaterialConnectionPoint;
  52805. /**
  52806. * Gets the g component (input)
  52807. */
  52808. readonly g: NodeMaterialConnectionPoint;
  52809. /**
  52810. * Gets the b component (input)
  52811. */
  52812. readonly b: NodeMaterialConnectionPoint;
  52813. /**
  52814. * Gets the a component (input)
  52815. */
  52816. readonly a: NodeMaterialConnectionPoint;
  52817. /**
  52818. * Gets the rgba component (output)
  52819. */
  52820. readonly rgba: NodeMaterialConnectionPoint;
  52821. /**
  52822. * Gets the rgb component (output)
  52823. */
  52824. readonly rgb: NodeMaterialConnectionPoint;
  52825. protected _buildBlock(state: NodeMaterialBuildState): this;
  52826. }
  52827. }
  52828. declare module BABYLON {
  52829. /**
  52830. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  52831. */
  52832. export class VectorMergerBlock extends NodeMaterialBlock {
  52833. /**
  52834. * Create a new VectorMergerBlock
  52835. * @param name defines the block name
  52836. */
  52837. constructor(name: string);
  52838. /**
  52839. * Gets the current class name
  52840. * @returns the class name
  52841. */
  52842. getClassName(): string;
  52843. /**
  52844. * Gets the x component (input)
  52845. */
  52846. readonly x: NodeMaterialConnectionPoint;
  52847. /**
  52848. * Gets the y component (input)
  52849. */
  52850. readonly y: NodeMaterialConnectionPoint;
  52851. /**
  52852. * Gets the z component (input)
  52853. */
  52854. readonly z: NodeMaterialConnectionPoint;
  52855. /**
  52856. * Gets the w component (input)
  52857. */
  52858. readonly w: NodeMaterialConnectionPoint;
  52859. /**
  52860. * Gets the xyzw component (output)
  52861. */
  52862. readonly xyzw: NodeMaterialConnectionPoint;
  52863. /**
  52864. * Gets the xyz component (output)
  52865. */
  52866. readonly xyz: NodeMaterialConnectionPoint;
  52867. /**
  52868. * Gets the xy component (output)
  52869. */
  52870. readonly xy: NodeMaterialConnectionPoint;
  52871. protected _buildBlock(state: NodeMaterialBuildState): this;
  52872. }
  52873. }
  52874. declare module BABYLON {
  52875. /**
  52876. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  52877. */
  52878. export class ColorSplitterBlock extends NodeMaterialBlock {
  52879. /**
  52880. * Create a new ColorSplitterBlock
  52881. * @param name defines the block name
  52882. */
  52883. constructor(name: string);
  52884. /**
  52885. * Gets the current class name
  52886. * @returns the class name
  52887. */
  52888. getClassName(): string;
  52889. /**
  52890. * Gets the rgba component (input)
  52891. */
  52892. readonly rgba: NodeMaterialConnectionPoint;
  52893. /**
  52894. * Gets the rgb component (input)
  52895. */
  52896. readonly rgbIn: NodeMaterialConnectionPoint;
  52897. /**
  52898. * Gets the rgb component (output)
  52899. */
  52900. readonly rgbOut: NodeMaterialConnectionPoint;
  52901. /**
  52902. * Gets the r component (output)
  52903. */
  52904. readonly r: NodeMaterialConnectionPoint;
  52905. /**
  52906. * Gets the g component (output)
  52907. */
  52908. readonly g: NodeMaterialConnectionPoint;
  52909. /**
  52910. * Gets the b component (output)
  52911. */
  52912. readonly b: NodeMaterialConnectionPoint;
  52913. /**
  52914. * Gets the a component (output)
  52915. */
  52916. readonly a: NodeMaterialConnectionPoint;
  52917. protected _buildBlock(state: NodeMaterialBuildState): this;
  52918. }
  52919. }
  52920. declare module BABYLON {
  52921. /**
  52922. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  52923. */
  52924. export class VectorSplitterBlock extends NodeMaterialBlock {
  52925. /**
  52926. * Create a new VectorSplitterBlock
  52927. * @param name defines the block name
  52928. */
  52929. constructor(name: string);
  52930. /**
  52931. * Gets the current class name
  52932. * @returns the class name
  52933. */
  52934. getClassName(): string;
  52935. /**
  52936. * Gets the xyzw component (input)
  52937. */
  52938. readonly xyzw: NodeMaterialConnectionPoint;
  52939. /**
  52940. * Gets the xyz component (input)
  52941. */
  52942. readonly xyzIn: NodeMaterialConnectionPoint;
  52943. /**
  52944. * Gets the xyz component (output)
  52945. */
  52946. readonly xyzOut: NodeMaterialConnectionPoint;
  52947. /**
  52948. * Gets the xy component (output)
  52949. */
  52950. readonly xy: NodeMaterialConnectionPoint;
  52951. /**
  52952. * Gets the x component (output)
  52953. */
  52954. readonly x: NodeMaterialConnectionPoint;
  52955. /**
  52956. * Gets the y component (output)
  52957. */
  52958. readonly y: NodeMaterialConnectionPoint;
  52959. /**
  52960. * Gets the z component (output)
  52961. */
  52962. readonly z: NodeMaterialConnectionPoint;
  52963. /**
  52964. * Gets the w component (output)
  52965. */
  52966. readonly w: NodeMaterialConnectionPoint;
  52967. protected _buildBlock(state: NodeMaterialBuildState): this;
  52968. }
  52969. }
  52970. declare module BABYLON {
  52971. /**
  52972. * Block used to add image processing support to fragment shader
  52973. */
  52974. export class ImageProcessingBlock extends NodeMaterialBlock {
  52975. /**
  52976. * Create a new ImageProcessingBlock
  52977. * @param name defines the block name
  52978. */
  52979. constructor(name: string);
  52980. /**
  52981. * Gets the current class name
  52982. * @returns the class name
  52983. */
  52984. getClassName(): string;
  52985. /**
  52986. * Gets the color input component
  52987. */
  52988. readonly color: NodeMaterialConnectionPoint;
  52989. /**
  52990. * Gets the output component
  52991. */
  52992. readonly output: NodeMaterialConnectionPoint;
  52993. /**
  52994. * Initialize the block and prepare the context for build
  52995. * @param state defines the state that will be used for the build
  52996. */
  52997. initialize(state: NodeMaterialBuildState): void;
  52998. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53000. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53001. protected _buildBlock(state: NodeMaterialBuildState): this;
  53002. }
  53003. }
  53004. declare module BABYLON {
  53005. /**
  53006. * Block used to add support for scene fog
  53007. */
  53008. export class FogBlock extends NodeMaterialBlock {
  53009. private _fogDistanceName;
  53010. private _fogParameters;
  53011. /**
  53012. * Create a new FogBlock
  53013. * @param name defines the block name
  53014. */
  53015. constructor(name: string);
  53016. /**
  53017. * Gets the current class name
  53018. * @returns the class name
  53019. */
  53020. getClassName(): string;
  53021. /**
  53022. * Gets the world position input component
  53023. */
  53024. readonly worldPosition: NodeMaterialConnectionPoint;
  53025. /**
  53026. * Gets the view input component
  53027. */
  53028. readonly view: NodeMaterialConnectionPoint;
  53029. /**
  53030. * Gets the color input component
  53031. */
  53032. readonly color: NodeMaterialConnectionPoint;
  53033. /**
  53034. * Gets the fog color input component
  53035. */
  53036. readonly fogColor: NodeMaterialConnectionPoint;
  53037. /**
  53038. * Gets the output component
  53039. */
  53040. readonly output: NodeMaterialConnectionPoint;
  53041. autoConfigure(): void;
  53042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53043. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53044. protected _buildBlock(state: NodeMaterialBuildState): this;
  53045. }
  53046. }
  53047. declare module BABYLON {
  53048. /**
  53049. * Block used to add light in the fragment shader
  53050. */
  53051. export class LightBlock extends NodeMaterialBlock {
  53052. private _lightId;
  53053. /**
  53054. * Gets or sets the light associated with this block
  53055. */
  53056. light: Nullable<Light>;
  53057. /**
  53058. * Create a new LightBlock
  53059. * @param name defines the block name
  53060. */
  53061. constructor(name: string);
  53062. /**
  53063. * Gets the current class name
  53064. * @returns the class name
  53065. */
  53066. getClassName(): string;
  53067. /**
  53068. * Gets the world position input component
  53069. */
  53070. readonly worldPosition: NodeMaterialConnectionPoint;
  53071. /**
  53072. * Gets the world normal input component
  53073. */
  53074. readonly worldNormal: NodeMaterialConnectionPoint;
  53075. /**
  53076. * Gets the camera (or eye) position component
  53077. */
  53078. readonly cameraPosition: NodeMaterialConnectionPoint;
  53079. /**
  53080. * Gets the diffuse output component
  53081. */
  53082. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53083. /**
  53084. * Gets the specular output component
  53085. */
  53086. readonly specularOutput: NodeMaterialConnectionPoint;
  53087. autoConfigure(): void;
  53088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53089. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53091. private _injectVertexCode;
  53092. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53093. serialize(): any;
  53094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53095. }
  53096. }
  53097. declare module BABYLON {
  53098. /**
  53099. * Block used to multiply 2 values
  53100. */
  53101. export class MultiplyBlock extends NodeMaterialBlock {
  53102. /**
  53103. * Creates a new MultiplyBlock
  53104. * @param name defines the block name
  53105. */
  53106. constructor(name: string);
  53107. /**
  53108. * Gets the current class name
  53109. * @returns the class name
  53110. */
  53111. getClassName(): string;
  53112. /**
  53113. * Gets the left operand input component
  53114. */
  53115. readonly left: NodeMaterialConnectionPoint;
  53116. /**
  53117. * Gets the right operand input component
  53118. */
  53119. readonly right: NodeMaterialConnectionPoint;
  53120. /**
  53121. * Gets the output component
  53122. */
  53123. readonly output: NodeMaterialConnectionPoint;
  53124. protected _buildBlock(state: NodeMaterialBuildState): this;
  53125. }
  53126. }
  53127. declare module BABYLON {
  53128. /**
  53129. * Block used to add 2 vectors
  53130. */
  53131. export class AddBlock extends NodeMaterialBlock {
  53132. /**
  53133. * Creates a new AddBlock
  53134. * @param name defines the block name
  53135. */
  53136. constructor(name: string);
  53137. /**
  53138. * Gets the current class name
  53139. * @returns the class name
  53140. */
  53141. getClassName(): string;
  53142. /**
  53143. * Gets the left operand input component
  53144. */
  53145. readonly left: NodeMaterialConnectionPoint;
  53146. /**
  53147. * Gets the right operand input component
  53148. */
  53149. readonly right: NodeMaterialConnectionPoint;
  53150. /**
  53151. * Gets the output component
  53152. */
  53153. readonly output: NodeMaterialConnectionPoint;
  53154. protected _buildBlock(state: NodeMaterialBuildState): this;
  53155. }
  53156. }
  53157. declare module BABYLON {
  53158. /**
  53159. * Block used to clamp a float
  53160. */
  53161. export class ClampBlock extends NodeMaterialBlock {
  53162. /** Gets or sets the minimum range */
  53163. minimum: number;
  53164. /** Gets or sets the maximum range */
  53165. maximum: number;
  53166. /**
  53167. * Creates a new ClampBlock
  53168. * @param name defines the block name
  53169. */
  53170. constructor(name: string);
  53171. /**
  53172. * Gets the current class name
  53173. * @returns the class name
  53174. */
  53175. getClassName(): string;
  53176. /**
  53177. * Gets the value input component
  53178. */
  53179. readonly value: NodeMaterialConnectionPoint;
  53180. /**
  53181. * Gets the output component
  53182. */
  53183. readonly output: NodeMaterialConnectionPoint;
  53184. protected _buildBlock(state: NodeMaterialBuildState): this;
  53185. }
  53186. }
  53187. declare module BABYLON {
  53188. /**
  53189. * Block used to apply a cross product between 2 vectors
  53190. */
  53191. export class CrossBlock extends NodeMaterialBlock {
  53192. /**
  53193. * Creates a new CrossBlock
  53194. * @param name defines the block name
  53195. */
  53196. constructor(name: string);
  53197. /**
  53198. * Gets the current class name
  53199. * @returns the class name
  53200. */
  53201. getClassName(): string;
  53202. /**
  53203. * Gets the left operand input component
  53204. */
  53205. readonly left: NodeMaterialConnectionPoint;
  53206. /**
  53207. * Gets the right operand input component
  53208. */
  53209. readonly right: NodeMaterialConnectionPoint;
  53210. /**
  53211. * Gets the output component
  53212. */
  53213. readonly output: NodeMaterialConnectionPoint;
  53214. protected _buildBlock(state: NodeMaterialBuildState): this;
  53215. }
  53216. }
  53217. declare module BABYLON {
  53218. /**
  53219. * Block used to apply a dot product between 2 vectors
  53220. */
  53221. export class DotBlock extends NodeMaterialBlock {
  53222. /**
  53223. * Creates a new DotBlock
  53224. * @param name defines the block name
  53225. */
  53226. constructor(name: string);
  53227. /**
  53228. * Gets the current class name
  53229. * @returns the class name
  53230. */
  53231. getClassName(): string;
  53232. /**
  53233. * Gets the left operand input component
  53234. */
  53235. readonly left: NodeMaterialConnectionPoint;
  53236. /**
  53237. * Gets the right operand input component
  53238. */
  53239. readonly right: NodeMaterialConnectionPoint;
  53240. /**
  53241. * Gets the output component
  53242. */
  53243. readonly output: NodeMaterialConnectionPoint;
  53244. protected _buildBlock(state: NodeMaterialBuildState): this;
  53245. }
  53246. }
  53247. declare module BABYLON {
  53248. /**
  53249. * Block used to remap a float from a range to a new one
  53250. */
  53251. export class RemapBlock extends NodeMaterialBlock {
  53252. /**
  53253. * Gets or sets the source range
  53254. */
  53255. sourceRange: Vector2;
  53256. /**
  53257. * Gets or sets the target range
  53258. */
  53259. targetRange: Vector2;
  53260. /**
  53261. * Creates a new RemapBlock
  53262. * @param name defines the block name
  53263. */
  53264. constructor(name: string);
  53265. /**
  53266. * Gets the current class name
  53267. * @returns the class name
  53268. */
  53269. getClassName(): string;
  53270. /**
  53271. * Gets the input component
  53272. */
  53273. readonly input: NodeMaterialConnectionPoint;
  53274. /**
  53275. * Gets the output component
  53276. */
  53277. readonly output: NodeMaterialConnectionPoint;
  53278. protected _buildBlock(state: NodeMaterialBuildState): this;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /**
  53283. * Block used to normalize a vector
  53284. */
  53285. export class NormalizeBlock extends NodeMaterialBlock {
  53286. /**
  53287. * Creates a new NormalizeBlock
  53288. * @param name defines the block name
  53289. */
  53290. constructor(name: string);
  53291. /**
  53292. * Gets the current class name
  53293. * @returns the class name
  53294. */
  53295. getClassName(): string;
  53296. /**
  53297. * Gets the input component
  53298. */
  53299. readonly input: NodeMaterialConnectionPoint;
  53300. /**
  53301. * Gets the output component
  53302. */
  53303. readonly output: NodeMaterialConnectionPoint;
  53304. protected _buildBlock(state: NodeMaterialBuildState): this;
  53305. }
  53306. }
  53307. declare module BABYLON {
  53308. /**
  53309. * Effect Render Options
  53310. */
  53311. export interface IEffectRendererOptions {
  53312. /**
  53313. * Defines the vertices positions.
  53314. */
  53315. positions?: number[];
  53316. /**
  53317. * Defines the indices.
  53318. */
  53319. indices?: number[];
  53320. }
  53321. /**
  53322. * Helper class to render one or more effects
  53323. */
  53324. export class EffectRenderer {
  53325. private engine;
  53326. private static _DefaultOptions;
  53327. private _vertexBuffers;
  53328. private _indexBuffer;
  53329. private _ringBufferIndex;
  53330. private _ringScreenBuffer;
  53331. private _fullscreenViewport;
  53332. private _getNextFrameBuffer;
  53333. /**
  53334. * Creates an effect renderer
  53335. * @param engine the engine to use for rendering
  53336. * @param options defines the options of the effect renderer
  53337. */
  53338. constructor(engine: Engine, options?: IEffectRendererOptions);
  53339. /**
  53340. * Sets the current viewport in normalized coordinates 0-1
  53341. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53342. */
  53343. setViewport(viewport?: Viewport): void;
  53344. /**
  53345. * Sets the current effect wrapper to use during draw.
  53346. * The effect needs to be ready before calling this api.
  53347. * This also sets the default full screen position attribute.
  53348. * @param effectWrapper Defines the effect to draw with
  53349. */
  53350. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53351. /**
  53352. * Draws a full screen quad.
  53353. */
  53354. draw(): void;
  53355. /**
  53356. * renders one or more effects to a specified texture
  53357. * @param effectWrappers list of effects to renderer
  53358. * @param outputTexture texture to draw to, if null it will render to the screen
  53359. */
  53360. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53361. /**
  53362. * Disposes of the effect renderer
  53363. */
  53364. dispose(): void;
  53365. }
  53366. /**
  53367. * Options to create an EffectWrapper
  53368. */
  53369. interface EffectWrapperCreationOptions {
  53370. /**
  53371. * Engine to use to create the effect
  53372. */
  53373. engine: Engine;
  53374. /**
  53375. * Fragment shader for the effect
  53376. */
  53377. fragmentShader: string;
  53378. /**
  53379. * Vertex shader for the effect
  53380. */
  53381. vertexShader?: string;
  53382. /**
  53383. * Attributes to use in the shader
  53384. */
  53385. attributeNames?: Array<string>;
  53386. /**
  53387. * Uniforms to use in the shader
  53388. */
  53389. uniformNames?: Array<string>;
  53390. /**
  53391. * Texture sampler names to use in the shader
  53392. */
  53393. samplerNames?: Array<string>;
  53394. /**
  53395. * The friendly name of the effect displayed in Spector.
  53396. */
  53397. name?: string;
  53398. }
  53399. /**
  53400. * Wraps an effect to be used for rendering
  53401. */
  53402. export class EffectWrapper {
  53403. /**
  53404. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53405. */
  53406. onApplyObservable: Observable<{}>;
  53407. /**
  53408. * The underlying effect
  53409. */
  53410. effect: Effect;
  53411. /**
  53412. * Creates an effect to be renderer
  53413. * @param creationOptions options to create the effect
  53414. */
  53415. constructor(creationOptions: EffectWrapperCreationOptions);
  53416. /**
  53417. * Disposes of the effect wrapper
  53418. */
  53419. dispose(): void;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /**
  53424. * Helper class to push actions to a pool of workers.
  53425. */
  53426. export class WorkerPool implements IDisposable {
  53427. private _workerInfos;
  53428. private _pendingActions;
  53429. /**
  53430. * Constructor
  53431. * @param workers Array of workers to use for actions
  53432. */
  53433. constructor(workers: Array<Worker>);
  53434. /**
  53435. * Terminates all workers and clears any pending actions.
  53436. */
  53437. dispose(): void;
  53438. /**
  53439. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53440. * pended until a worker has completed its action.
  53441. * @param action The action to perform. Call onComplete when the action is complete.
  53442. */
  53443. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53444. private _execute;
  53445. }
  53446. }
  53447. declare module BABYLON {
  53448. /**
  53449. * Configuration for Draco compression
  53450. */
  53451. export interface IDracoCompressionConfiguration {
  53452. /**
  53453. * Configuration for the decoder.
  53454. */
  53455. decoder: {
  53456. /**
  53457. * The url to the WebAssembly module.
  53458. */
  53459. wasmUrl?: string;
  53460. /**
  53461. * The url to the WebAssembly binary.
  53462. */
  53463. wasmBinaryUrl?: string;
  53464. /**
  53465. * The url to the fallback JavaScript module.
  53466. */
  53467. fallbackUrl?: string;
  53468. };
  53469. }
  53470. /**
  53471. * Draco compression (https://google.github.io/draco/)
  53472. *
  53473. * This class wraps the Draco module.
  53474. *
  53475. * **Encoder**
  53476. *
  53477. * The encoder is not currently implemented.
  53478. *
  53479. * **Decoder**
  53480. *
  53481. * 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.
  53482. *
  53483. * To update the configuration, use the following code:
  53484. * ```javascript
  53485. * DracoCompression.Configuration = {
  53486. * decoder: {
  53487. * wasmUrl: "<url to the WebAssembly library>",
  53488. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53489. * fallbackUrl: "<url to the fallback JavaScript library>",
  53490. * }
  53491. * };
  53492. * ```
  53493. *
  53494. * 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.
  53495. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53496. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53497. *
  53498. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53499. * ```javascript
  53500. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53501. * ```
  53502. *
  53503. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53504. */
  53505. export class DracoCompression implements IDisposable {
  53506. private _workerPoolPromise?;
  53507. private _decoderModulePromise?;
  53508. /**
  53509. * The configuration. Defaults to the following urls:
  53510. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53511. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53512. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53513. */
  53514. static Configuration: IDracoCompressionConfiguration;
  53515. /**
  53516. * Returns true if the decoder configuration is available.
  53517. */
  53518. static readonly DecoderAvailable: boolean;
  53519. /**
  53520. * Default number of workers to create when creating the draco compression object.
  53521. */
  53522. static DefaultNumWorkers: number;
  53523. private static GetDefaultNumWorkers;
  53524. private static _Default;
  53525. /**
  53526. * Default instance for the draco compression object.
  53527. */
  53528. static readonly Default: DracoCompression;
  53529. /**
  53530. * Constructor
  53531. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53532. */
  53533. constructor(numWorkers?: number);
  53534. /**
  53535. * Stop all async operations and release resources.
  53536. */
  53537. dispose(): void;
  53538. /**
  53539. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53540. * @returns a promise that resolves when ready
  53541. */
  53542. whenReadyAsync(): Promise<void>;
  53543. /**
  53544. * Decode Draco compressed mesh data to vertex data.
  53545. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53546. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53547. * @returns A promise that resolves with the decoded vertex data
  53548. */
  53549. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53550. [kind: string]: number;
  53551. }): Promise<VertexData>;
  53552. }
  53553. }
  53554. declare module BABYLON {
  53555. /**
  53556. * Class for building Constructive Solid Geometry
  53557. */
  53558. export class CSG {
  53559. private polygons;
  53560. /**
  53561. * The world matrix
  53562. */
  53563. matrix: Matrix;
  53564. /**
  53565. * Stores the position
  53566. */
  53567. position: Vector3;
  53568. /**
  53569. * Stores the rotation
  53570. */
  53571. rotation: Vector3;
  53572. /**
  53573. * Stores the rotation quaternion
  53574. */
  53575. rotationQuaternion: Nullable<Quaternion>;
  53576. /**
  53577. * Stores the scaling vector
  53578. */
  53579. scaling: Vector3;
  53580. /**
  53581. * Convert the Mesh to CSG
  53582. * @param mesh The Mesh to convert to CSG
  53583. * @returns A new CSG from the Mesh
  53584. */
  53585. static FromMesh(mesh: Mesh): CSG;
  53586. /**
  53587. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53588. * @param polygons Polygons used to construct a CSG solid
  53589. */
  53590. private static FromPolygons;
  53591. /**
  53592. * Clones, or makes a deep copy, of the CSG
  53593. * @returns A new CSG
  53594. */
  53595. clone(): CSG;
  53596. /**
  53597. * Unions this CSG with another CSG
  53598. * @param csg The CSG to union against this CSG
  53599. * @returns The unioned CSG
  53600. */
  53601. union(csg: CSG): CSG;
  53602. /**
  53603. * Unions this CSG with another CSG in place
  53604. * @param csg The CSG to union against this CSG
  53605. */
  53606. unionInPlace(csg: CSG): void;
  53607. /**
  53608. * Subtracts this CSG with another CSG
  53609. * @param csg The CSG to subtract against this CSG
  53610. * @returns A new CSG
  53611. */
  53612. subtract(csg: CSG): CSG;
  53613. /**
  53614. * Subtracts this CSG with another CSG in place
  53615. * @param csg The CSG to subtact against this CSG
  53616. */
  53617. subtractInPlace(csg: CSG): void;
  53618. /**
  53619. * Intersect this CSG with another CSG
  53620. * @param csg The CSG to intersect against this CSG
  53621. * @returns A new CSG
  53622. */
  53623. intersect(csg: CSG): CSG;
  53624. /**
  53625. * Intersects this CSG with another CSG in place
  53626. * @param csg The CSG to intersect against this CSG
  53627. */
  53628. intersectInPlace(csg: CSG): void;
  53629. /**
  53630. * Return a new CSG solid with solid and empty space switched. This solid is
  53631. * not modified.
  53632. * @returns A new CSG solid with solid and empty space switched
  53633. */
  53634. inverse(): CSG;
  53635. /**
  53636. * Inverses the CSG in place
  53637. */
  53638. inverseInPlace(): void;
  53639. /**
  53640. * This is used to keep meshes transformations so they can be restored
  53641. * when we build back a Babylon Mesh
  53642. * NB : All CSG operations are performed in world coordinates
  53643. * @param csg The CSG to copy the transform attributes from
  53644. * @returns This CSG
  53645. */
  53646. copyTransformAttributes(csg: CSG): CSG;
  53647. /**
  53648. * Build Raw mesh from CSG
  53649. * Coordinates here are in world space
  53650. * @param name The name of the mesh geometry
  53651. * @param scene The Scene
  53652. * @param keepSubMeshes Specifies if the submeshes should be kept
  53653. * @returns A new Mesh
  53654. */
  53655. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53656. /**
  53657. * Build Mesh from CSG taking material and transforms into account
  53658. * @param name The name of the Mesh
  53659. * @param material The material of the Mesh
  53660. * @param scene The Scene
  53661. * @param keepSubMeshes Specifies if submeshes should be kept
  53662. * @returns The new Mesh
  53663. */
  53664. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53665. }
  53666. }
  53667. declare module BABYLON {
  53668. /**
  53669. * Class used to create a trail following a mesh
  53670. */
  53671. export class TrailMesh extends Mesh {
  53672. private _generator;
  53673. private _autoStart;
  53674. private _running;
  53675. private _diameter;
  53676. private _length;
  53677. private _sectionPolygonPointsCount;
  53678. private _sectionVectors;
  53679. private _sectionNormalVectors;
  53680. private _beforeRenderObserver;
  53681. /**
  53682. * @constructor
  53683. * @param name The value used by scene.getMeshByName() to do a lookup.
  53684. * @param generator The mesh to generate a trail.
  53685. * @param scene The scene to add this mesh to.
  53686. * @param diameter Diameter of trailing mesh. Default is 1.
  53687. * @param length Length of trailing mesh. Default is 60.
  53688. * @param autoStart Automatically start trailing mesh. Default true.
  53689. */
  53690. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53691. /**
  53692. * "TrailMesh"
  53693. * @returns "TrailMesh"
  53694. */
  53695. getClassName(): string;
  53696. private _createMesh;
  53697. /**
  53698. * Start trailing mesh.
  53699. */
  53700. start(): void;
  53701. /**
  53702. * Stop trailing mesh.
  53703. */
  53704. stop(): void;
  53705. /**
  53706. * Update trailing mesh geometry.
  53707. */
  53708. update(): void;
  53709. /**
  53710. * Returns a new TrailMesh object.
  53711. * @param name is a string, the name given to the new mesh
  53712. * @param newGenerator use new generator object for cloned trail mesh
  53713. * @returns a new mesh
  53714. */
  53715. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53716. /**
  53717. * Serializes this trail mesh
  53718. * @param serializationObject object to write serialization to
  53719. */
  53720. serialize(serializationObject: any): void;
  53721. /**
  53722. * Parses a serialized trail mesh
  53723. * @param parsedMesh the serialized mesh
  53724. * @param scene the scene to create the trail mesh in
  53725. * @returns the created trail mesh
  53726. */
  53727. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53728. }
  53729. }
  53730. declare module BABYLON {
  53731. /**
  53732. * Class containing static functions to help procedurally build meshes
  53733. */
  53734. export class TiledBoxBuilder {
  53735. /**
  53736. * Creates a box mesh
  53737. * 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)
  53738. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53740. * * 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
  53741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53742. * @param name defines the name of the mesh
  53743. * @param options defines the options used to create the mesh
  53744. * @param scene defines the hosting scene
  53745. * @returns the box mesh
  53746. */
  53747. static CreateTiledBox(name: string, options: {
  53748. pattern?: number;
  53749. width?: number;
  53750. height?: number;
  53751. depth?: number;
  53752. tileSize?: number;
  53753. tileWidth?: number;
  53754. tileHeight?: number;
  53755. alignHorizontal?: number;
  53756. alignVertical?: number;
  53757. faceUV?: Vector4[];
  53758. faceColors?: Color4[];
  53759. sideOrientation?: number;
  53760. updatable?: boolean;
  53761. }, scene?: Nullable<Scene>): Mesh;
  53762. }
  53763. }
  53764. declare module BABYLON {
  53765. /**
  53766. * Class containing static functions to help procedurally build meshes
  53767. */
  53768. export class TorusKnotBuilder {
  53769. /**
  53770. * Creates a torus knot mesh
  53771. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53772. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53773. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53774. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53776. * * 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
  53777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53778. * @param name defines the name of the mesh
  53779. * @param options defines the options used to create the mesh
  53780. * @param scene defines the hosting scene
  53781. * @returns the torus knot mesh
  53782. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53783. */
  53784. static CreateTorusKnot(name: string, options: {
  53785. radius?: number;
  53786. tube?: number;
  53787. radialSegments?: number;
  53788. tubularSegments?: number;
  53789. p?: number;
  53790. q?: number;
  53791. updatable?: boolean;
  53792. sideOrientation?: number;
  53793. frontUVs?: Vector4;
  53794. backUVs?: Vector4;
  53795. }, scene: any): Mesh;
  53796. }
  53797. }
  53798. declare module BABYLON {
  53799. /**
  53800. * Polygon
  53801. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53802. */
  53803. export class Polygon {
  53804. /**
  53805. * Creates a rectangle
  53806. * @param xmin bottom X coord
  53807. * @param ymin bottom Y coord
  53808. * @param xmax top X coord
  53809. * @param ymax top Y coord
  53810. * @returns points that make the resulting rectation
  53811. */
  53812. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53813. /**
  53814. * Creates a circle
  53815. * @param radius radius of circle
  53816. * @param cx scale in x
  53817. * @param cy scale in y
  53818. * @param numberOfSides number of sides that make up the circle
  53819. * @returns points that make the resulting circle
  53820. */
  53821. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53822. /**
  53823. * Creates a polygon from input string
  53824. * @param input Input polygon data
  53825. * @returns the parsed points
  53826. */
  53827. static Parse(input: string): Vector2[];
  53828. /**
  53829. * Starts building a polygon from x and y coordinates
  53830. * @param x x coordinate
  53831. * @param y y coordinate
  53832. * @returns the started path2
  53833. */
  53834. static StartingAt(x: number, y: number): Path2;
  53835. }
  53836. /**
  53837. * Builds a polygon
  53838. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53839. */
  53840. export class PolygonMeshBuilder {
  53841. private _points;
  53842. private _outlinepoints;
  53843. private _holes;
  53844. private _name;
  53845. private _scene;
  53846. private _epoints;
  53847. private _eholes;
  53848. private _addToepoint;
  53849. /**
  53850. * Babylon reference to the earcut plugin.
  53851. */
  53852. bjsEarcut: any;
  53853. /**
  53854. * Creates a PolygonMeshBuilder
  53855. * @param name name of the builder
  53856. * @param contours Path of the polygon
  53857. * @param scene scene to add to when creating the mesh
  53858. * @param earcutInjection can be used to inject your own earcut reference
  53859. */
  53860. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53861. /**
  53862. * Adds a whole within the polygon
  53863. * @param hole Array of points defining the hole
  53864. * @returns this
  53865. */
  53866. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53867. /**
  53868. * Creates the polygon
  53869. * @param updatable If the mesh should be updatable
  53870. * @param depth The depth of the mesh created
  53871. * @returns the created mesh
  53872. */
  53873. build(updatable?: boolean, depth?: number): Mesh;
  53874. /**
  53875. * Creates the polygon
  53876. * @param depth The depth of the mesh created
  53877. * @returns the created VertexData
  53878. */
  53879. buildVertexData(depth?: number): VertexData;
  53880. /**
  53881. * Adds a side to the polygon
  53882. * @param positions points that make the polygon
  53883. * @param normals normals of the polygon
  53884. * @param uvs uvs of the polygon
  53885. * @param indices indices of the polygon
  53886. * @param bounds bounds of the polygon
  53887. * @param points points of the polygon
  53888. * @param depth depth of the polygon
  53889. * @param flip flip of the polygon
  53890. */
  53891. private addSide;
  53892. }
  53893. }
  53894. declare module BABYLON {
  53895. /**
  53896. * Class containing static functions to help procedurally build meshes
  53897. */
  53898. export class PolygonBuilder {
  53899. /**
  53900. * Creates a polygon mesh
  53901. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53902. * * 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
  53903. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53905. * * 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)
  53906. * * Remember you can only change the shape positions, not their number when updating a polygon
  53907. * @param name defines the name of the mesh
  53908. * @param options defines the options used to create the mesh
  53909. * @param scene defines the hosting scene
  53910. * @param earcutInjection can be used to inject your own earcut reference
  53911. * @returns the polygon mesh
  53912. */
  53913. static CreatePolygon(name: string, options: {
  53914. shape: Vector3[];
  53915. holes?: Vector3[][];
  53916. depth?: number;
  53917. faceUV?: Vector4[];
  53918. faceColors?: Color4[];
  53919. updatable?: boolean;
  53920. sideOrientation?: number;
  53921. frontUVs?: Vector4;
  53922. backUVs?: Vector4;
  53923. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53924. /**
  53925. * Creates an extruded polygon mesh, with depth in the Y direction.
  53926. * * 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)
  53927. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53928. * @param name defines the name of the mesh
  53929. * @param options defines the options used to create the mesh
  53930. * @param scene defines the hosting scene
  53931. * @param earcutInjection can be used to inject your own earcut reference
  53932. * @returns the polygon mesh
  53933. */
  53934. static ExtrudePolygon(name: string, options: {
  53935. shape: Vector3[];
  53936. holes?: Vector3[][];
  53937. depth?: number;
  53938. faceUV?: Vector4[];
  53939. faceColors?: Color4[];
  53940. updatable?: boolean;
  53941. sideOrientation?: number;
  53942. frontUVs?: Vector4;
  53943. backUVs?: Vector4;
  53944. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53945. }
  53946. }
  53947. declare module BABYLON {
  53948. /**
  53949. * Class containing static functions to help procedurally build meshes
  53950. */
  53951. export class LatheBuilder {
  53952. /**
  53953. * Creates lathe mesh.
  53954. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53955. * * 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
  53956. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53957. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53958. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53959. * * 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
  53960. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53961. * * 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
  53962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53963. * * 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
  53964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53966. * @param name defines the name of the mesh
  53967. * @param options defines the options used to create the mesh
  53968. * @param scene defines the hosting scene
  53969. * @returns the lathe mesh
  53970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53971. */
  53972. static CreateLathe(name: string, options: {
  53973. shape: Vector3[];
  53974. radius?: number;
  53975. tessellation?: number;
  53976. clip?: number;
  53977. arc?: number;
  53978. closed?: boolean;
  53979. updatable?: boolean;
  53980. sideOrientation?: number;
  53981. frontUVs?: Vector4;
  53982. backUVs?: Vector4;
  53983. cap?: number;
  53984. invertUV?: boolean;
  53985. }, scene?: Nullable<Scene>): Mesh;
  53986. }
  53987. }
  53988. declare module BABYLON {
  53989. /**
  53990. * Class containing static functions to help procedurally build meshes
  53991. */
  53992. export class TiledPlaneBuilder {
  53993. /**
  53994. * Creates a tiled plane mesh
  53995. * * The parameter `pattern` will, depending on value, do nothing or
  53996. * * * flip (reflect about central vertical) alternate tiles across and up
  53997. * * * flip every tile on alternate rows
  53998. * * * rotate (180 degs) alternate tiles across and up
  53999. * * * rotate every tile on alternate rows
  54000. * * * flip and rotate alternate tiles across and up
  54001. * * * flip and rotate every tile on alternate rows
  54002. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54003. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54004. * * 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
  54005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54006. * * 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)
  54007. * * 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)
  54008. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54009. * @param name defines the name of the mesh
  54010. * @param options defines the options used to create the mesh
  54011. * @param scene defines the hosting scene
  54012. * @returns the box mesh
  54013. */
  54014. static CreateTiledPlane(name: string, options: {
  54015. pattern?: number;
  54016. tileSize?: number;
  54017. tileWidth?: number;
  54018. tileHeight?: number;
  54019. size?: number;
  54020. width?: number;
  54021. height?: number;
  54022. alignHorizontal?: number;
  54023. alignVertical?: number;
  54024. sideOrientation?: number;
  54025. frontUVs?: Vector4;
  54026. backUVs?: Vector4;
  54027. updatable?: boolean;
  54028. }, scene?: Nullable<Scene>): Mesh;
  54029. }
  54030. }
  54031. declare module BABYLON {
  54032. /**
  54033. * Class containing static functions to help procedurally build meshes
  54034. */
  54035. export class TubeBuilder {
  54036. /**
  54037. * Creates a tube mesh.
  54038. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54039. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54040. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54041. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54042. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54043. * * 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)
  54044. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54045. * * 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
  54046. * * 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
  54047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54048. * * 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
  54049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54051. * @param name defines the name of the mesh
  54052. * @param options defines the options used to create the mesh
  54053. * @param scene defines the hosting scene
  54054. * @returns the tube mesh
  54055. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54056. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54057. */
  54058. static CreateTube(name: string, options: {
  54059. path: Vector3[];
  54060. radius?: number;
  54061. tessellation?: number;
  54062. radiusFunction?: {
  54063. (i: number, distance: number): number;
  54064. };
  54065. cap?: number;
  54066. arc?: number;
  54067. updatable?: boolean;
  54068. sideOrientation?: number;
  54069. frontUVs?: Vector4;
  54070. backUVs?: Vector4;
  54071. instance?: Mesh;
  54072. invertUV?: boolean;
  54073. }, scene?: Nullable<Scene>): Mesh;
  54074. }
  54075. }
  54076. declare module BABYLON {
  54077. /**
  54078. * Class containing static functions to help procedurally build meshes
  54079. */
  54080. export class IcoSphereBuilder {
  54081. /**
  54082. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54083. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54084. * * 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`)
  54085. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54086. * * 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
  54087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54088. * * 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
  54089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54090. * @param name defines the name of the mesh
  54091. * @param options defines the options used to create the mesh
  54092. * @param scene defines the hosting scene
  54093. * @returns the icosahedron mesh
  54094. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54095. */
  54096. static CreateIcoSphere(name: string, options: {
  54097. radius?: number;
  54098. radiusX?: number;
  54099. radiusY?: number;
  54100. radiusZ?: number;
  54101. flat?: boolean;
  54102. subdivisions?: number;
  54103. sideOrientation?: number;
  54104. frontUVs?: Vector4;
  54105. backUVs?: Vector4;
  54106. updatable?: boolean;
  54107. }, scene?: Nullable<Scene>): Mesh;
  54108. }
  54109. }
  54110. declare module BABYLON {
  54111. /**
  54112. * Class containing static functions to help procedurally build meshes
  54113. */
  54114. export class DecalBuilder {
  54115. /**
  54116. * Creates a decal mesh.
  54117. * 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
  54118. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54119. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54120. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54121. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54122. * @param name defines the name of the mesh
  54123. * @param sourceMesh defines the mesh where the decal must be applied
  54124. * @param options defines the options used to create the mesh
  54125. * @param scene defines the hosting scene
  54126. * @returns the decal mesh
  54127. * @see https://doc.babylonjs.com/how_to/decals
  54128. */
  54129. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54130. position?: Vector3;
  54131. normal?: Vector3;
  54132. size?: Vector3;
  54133. angle?: number;
  54134. }): Mesh;
  54135. }
  54136. }
  54137. declare module BABYLON {
  54138. /**
  54139. * Class containing static functions to help procedurally build meshes
  54140. */
  54141. export class MeshBuilder {
  54142. /**
  54143. * Creates a box mesh
  54144. * * The parameter `size` sets the size (float) of each box side (default 1)
  54145. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54146. * * 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)
  54147. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54149. * * 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
  54150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54151. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54152. * @param name defines the name of the mesh
  54153. * @param options defines the options used to create the mesh
  54154. * @param scene defines the hosting scene
  54155. * @returns the box mesh
  54156. */
  54157. static CreateBox(name: string, options: {
  54158. size?: number;
  54159. width?: number;
  54160. height?: number;
  54161. depth?: number;
  54162. faceUV?: Vector4[];
  54163. faceColors?: Color4[];
  54164. sideOrientation?: number;
  54165. frontUVs?: Vector4;
  54166. backUVs?: Vector4;
  54167. updatable?: boolean;
  54168. }, scene?: Nullable<Scene>): Mesh;
  54169. /**
  54170. * Creates a tiled box mesh
  54171. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54173. * @param name defines the name of the mesh
  54174. * @param options defines the options used to create the mesh
  54175. * @param scene defines the hosting scene
  54176. * @returns the tiled box mesh
  54177. */
  54178. static CreateTiledBox(name: string, options: {
  54179. pattern?: number;
  54180. size?: number;
  54181. width?: number;
  54182. height?: number;
  54183. depth: number;
  54184. tileSize?: number;
  54185. tileWidth?: number;
  54186. tileHeight?: number;
  54187. faceUV?: Vector4[];
  54188. faceColors?: Color4[];
  54189. alignHorizontal?: number;
  54190. alignVertical?: number;
  54191. sideOrientation?: number;
  54192. updatable?: boolean;
  54193. }, scene?: Nullable<Scene>): Mesh;
  54194. /**
  54195. * Creates a sphere mesh
  54196. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54197. * * 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`)
  54198. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54199. * * 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
  54200. * * 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)
  54201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54202. * * 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
  54203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54204. * @param name defines the name of the mesh
  54205. * @param options defines the options used to create the mesh
  54206. * @param scene defines the hosting scene
  54207. * @returns the sphere mesh
  54208. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54209. */
  54210. static CreateSphere(name: string, options: {
  54211. segments?: number;
  54212. diameter?: number;
  54213. diameterX?: number;
  54214. diameterY?: number;
  54215. diameterZ?: number;
  54216. arc?: number;
  54217. slice?: number;
  54218. sideOrientation?: number;
  54219. frontUVs?: Vector4;
  54220. backUVs?: Vector4;
  54221. updatable?: boolean;
  54222. }, scene?: Nullable<Scene>): Mesh;
  54223. /**
  54224. * Creates a plane polygonal mesh. By default, this is a disc
  54225. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54226. * * 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
  54227. * * 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
  54228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54229. * * 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
  54230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54231. * @param name defines the name of the mesh
  54232. * @param options defines the options used to create the mesh
  54233. * @param scene defines the hosting scene
  54234. * @returns the plane polygonal mesh
  54235. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54236. */
  54237. static CreateDisc(name: string, options: {
  54238. radius?: number;
  54239. tessellation?: number;
  54240. arc?: number;
  54241. updatable?: boolean;
  54242. sideOrientation?: number;
  54243. frontUVs?: Vector4;
  54244. backUVs?: Vector4;
  54245. }, scene?: Nullable<Scene>): Mesh;
  54246. /**
  54247. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54248. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54249. * * 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`)
  54250. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54251. * * 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
  54252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54253. * * 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
  54254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54255. * @param name defines the name of the mesh
  54256. * @param options defines the options used to create the mesh
  54257. * @param scene defines the hosting scene
  54258. * @returns the icosahedron mesh
  54259. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54260. */
  54261. static CreateIcoSphere(name: string, options: {
  54262. radius?: number;
  54263. radiusX?: number;
  54264. radiusY?: number;
  54265. radiusZ?: number;
  54266. flat?: boolean;
  54267. subdivisions?: number;
  54268. sideOrientation?: number;
  54269. frontUVs?: Vector4;
  54270. backUVs?: Vector4;
  54271. updatable?: boolean;
  54272. }, scene?: Nullable<Scene>): Mesh;
  54273. /**
  54274. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54275. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54276. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54277. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54278. * * 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
  54279. * * 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
  54280. * * 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
  54281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54282. * * 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
  54283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54284. * * 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
  54285. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54286. * * 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
  54287. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54289. * @param name defines the name of the mesh
  54290. * @param options defines the options used to create the mesh
  54291. * @param scene defines the hosting scene
  54292. * @returns the ribbon mesh
  54293. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54294. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54295. */
  54296. static CreateRibbon(name: string, options: {
  54297. pathArray: Vector3[][];
  54298. closeArray?: boolean;
  54299. closePath?: boolean;
  54300. offset?: number;
  54301. updatable?: boolean;
  54302. sideOrientation?: number;
  54303. frontUVs?: Vector4;
  54304. backUVs?: Vector4;
  54305. instance?: Mesh;
  54306. invertUV?: boolean;
  54307. uvs?: Vector2[];
  54308. colors?: Color4[];
  54309. }, scene?: Nullable<Scene>): Mesh;
  54310. /**
  54311. * Creates a cylinder or a cone mesh
  54312. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54313. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54314. * * 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.
  54315. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54316. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54317. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54318. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54319. * * 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).
  54320. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54321. * * 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).
  54322. * * 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
  54323. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54324. * * 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
  54325. * * 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.
  54326. * * If `enclose` is false, a ring surface is one element.
  54327. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54328. * * 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
  54329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54330. * * 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
  54331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54332. * @param name defines the name of the mesh
  54333. * @param options defines the options used to create the mesh
  54334. * @param scene defines the hosting scene
  54335. * @returns the cylinder mesh
  54336. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54337. */
  54338. static CreateCylinder(name: string, options: {
  54339. height?: number;
  54340. diameterTop?: number;
  54341. diameterBottom?: number;
  54342. diameter?: number;
  54343. tessellation?: number;
  54344. subdivisions?: number;
  54345. arc?: number;
  54346. faceColors?: Color4[];
  54347. faceUV?: Vector4[];
  54348. updatable?: boolean;
  54349. hasRings?: boolean;
  54350. enclose?: boolean;
  54351. cap?: number;
  54352. sideOrientation?: number;
  54353. frontUVs?: Vector4;
  54354. backUVs?: Vector4;
  54355. }, scene?: Nullable<Scene>): Mesh;
  54356. /**
  54357. * Creates a torus mesh
  54358. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54359. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54360. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54362. * * 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
  54363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54364. * @param name defines the name of the mesh
  54365. * @param options defines the options used to create the mesh
  54366. * @param scene defines the hosting scene
  54367. * @returns the torus mesh
  54368. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54369. */
  54370. static CreateTorus(name: string, options: {
  54371. diameter?: number;
  54372. thickness?: number;
  54373. tessellation?: number;
  54374. updatable?: boolean;
  54375. sideOrientation?: number;
  54376. frontUVs?: Vector4;
  54377. backUVs?: Vector4;
  54378. }, scene?: Nullable<Scene>): Mesh;
  54379. /**
  54380. * Creates a torus knot mesh
  54381. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54382. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54383. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54384. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54386. * * 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
  54387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54388. * @param name defines the name of the mesh
  54389. * @param options defines the options used to create the mesh
  54390. * @param scene defines the hosting scene
  54391. * @returns the torus knot mesh
  54392. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54393. */
  54394. static CreateTorusKnot(name: string, options: {
  54395. radius?: number;
  54396. tube?: number;
  54397. radialSegments?: number;
  54398. tubularSegments?: number;
  54399. p?: number;
  54400. q?: number;
  54401. updatable?: boolean;
  54402. sideOrientation?: number;
  54403. frontUVs?: Vector4;
  54404. backUVs?: Vector4;
  54405. }, scene?: Nullable<Scene>): Mesh;
  54406. /**
  54407. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54408. * * 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
  54409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54410. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54411. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54412. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54413. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54414. * * 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
  54415. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54418. * @param name defines the name of the new line system
  54419. * @param options defines the options used to create the line system
  54420. * @param scene defines the hosting scene
  54421. * @returns a new line system mesh
  54422. */
  54423. static CreateLineSystem(name: string, options: {
  54424. lines: Vector3[][];
  54425. updatable?: boolean;
  54426. instance?: Nullable<LinesMesh>;
  54427. colors?: Nullable<Color4[][]>;
  54428. useVertexAlpha?: boolean;
  54429. }, scene: Nullable<Scene>): LinesMesh;
  54430. /**
  54431. * Creates a line mesh
  54432. * 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
  54433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54434. * * The parameter `points` is an array successive Vector3
  54435. * * 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
  54436. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54437. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54438. * * When updating an instance, remember that only point positions can change, not the number of points
  54439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54441. * @param name defines the name of the new line system
  54442. * @param options defines the options used to create the line system
  54443. * @param scene defines the hosting scene
  54444. * @returns a new line mesh
  54445. */
  54446. static CreateLines(name: string, options: {
  54447. points: Vector3[];
  54448. updatable?: boolean;
  54449. instance?: Nullable<LinesMesh>;
  54450. colors?: Color4[];
  54451. useVertexAlpha?: boolean;
  54452. }, scene?: Nullable<Scene>): LinesMesh;
  54453. /**
  54454. * Creates a dashed line mesh
  54455. * * 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
  54456. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54457. * * The parameter `points` is an array successive Vector3
  54458. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54459. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54460. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54461. * * 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
  54462. * * When updating an instance, remember that only point positions can change, not the number of points
  54463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54464. * @param name defines the name of the mesh
  54465. * @param options defines the options used to create the mesh
  54466. * @param scene defines the hosting scene
  54467. * @returns the dashed line mesh
  54468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54469. */
  54470. static CreateDashedLines(name: string, options: {
  54471. points: Vector3[];
  54472. dashSize?: number;
  54473. gapSize?: number;
  54474. dashNb?: number;
  54475. updatable?: boolean;
  54476. instance?: LinesMesh;
  54477. }, scene?: Nullable<Scene>): LinesMesh;
  54478. /**
  54479. * 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.
  54480. * * 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.
  54481. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54482. * * 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.
  54483. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54484. * * 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
  54485. * * 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
  54486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54488. * * 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
  54489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54491. * @param name defines the name of the mesh
  54492. * @param options defines the options used to create the mesh
  54493. * @param scene defines the hosting scene
  54494. * @returns the extruded shape mesh
  54495. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54497. */
  54498. static ExtrudeShape(name: string, options: {
  54499. shape: Vector3[];
  54500. path: Vector3[];
  54501. scale?: number;
  54502. rotation?: number;
  54503. cap?: number;
  54504. updatable?: boolean;
  54505. sideOrientation?: number;
  54506. frontUVs?: Vector4;
  54507. backUVs?: Vector4;
  54508. instance?: Mesh;
  54509. invertUV?: boolean;
  54510. }, scene?: Nullable<Scene>): Mesh;
  54511. /**
  54512. * Creates an custom extruded shape mesh.
  54513. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54514. * * 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.
  54515. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54516. * * 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
  54517. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54518. * * 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
  54519. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54520. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54521. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54522. * * 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
  54523. * * 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
  54524. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54526. * * 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
  54527. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54529. * @param name defines the name of the mesh
  54530. * @param options defines the options used to create the mesh
  54531. * @param scene defines the hosting scene
  54532. * @returns the custom extruded shape mesh
  54533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54534. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54536. */
  54537. static ExtrudeShapeCustom(name: string, options: {
  54538. shape: Vector3[];
  54539. path: Vector3[];
  54540. scaleFunction?: any;
  54541. rotationFunction?: any;
  54542. ribbonCloseArray?: boolean;
  54543. ribbonClosePath?: boolean;
  54544. cap?: number;
  54545. updatable?: boolean;
  54546. sideOrientation?: number;
  54547. frontUVs?: Vector4;
  54548. backUVs?: Vector4;
  54549. instance?: Mesh;
  54550. invertUV?: boolean;
  54551. }, scene?: Nullable<Scene>): Mesh;
  54552. /**
  54553. * Creates lathe mesh.
  54554. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54555. * * 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
  54556. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54557. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54558. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54559. * * 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
  54560. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54561. * * 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
  54562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54563. * * 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
  54564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54566. * @param name defines the name of the mesh
  54567. * @param options defines the options used to create the mesh
  54568. * @param scene defines the hosting scene
  54569. * @returns the lathe mesh
  54570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54571. */
  54572. static CreateLathe(name: string, options: {
  54573. shape: Vector3[];
  54574. radius?: number;
  54575. tessellation?: number;
  54576. clip?: number;
  54577. arc?: number;
  54578. closed?: boolean;
  54579. updatable?: boolean;
  54580. sideOrientation?: number;
  54581. frontUVs?: Vector4;
  54582. backUVs?: Vector4;
  54583. cap?: number;
  54584. invertUV?: boolean;
  54585. }, scene?: Nullable<Scene>): Mesh;
  54586. /**
  54587. * Creates a tiled plane mesh
  54588. * * You can set a limited pattern arrangement with the tiles
  54589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54590. * * 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
  54591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54592. * @param name defines the name of the mesh
  54593. * @param options defines the options used to create the mesh
  54594. * @param scene defines the hosting scene
  54595. * @returns the plane mesh
  54596. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54597. */
  54598. static CreateTiledPlane(name: string, options: {
  54599. pattern?: number;
  54600. tileSize?: number;
  54601. tileWidth?: number;
  54602. tileHeight?: number;
  54603. size?: number;
  54604. width?: number;
  54605. height?: number;
  54606. alignHorizontal?: number;
  54607. alignVertical?: number;
  54608. sideOrientation?: number;
  54609. frontUVs?: Vector4;
  54610. backUVs?: Vector4;
  54611. updatable?: boolean;
  54612. }, scene?: Nullable<Scene>): Mesh;
  54613. /**
  54614. * Creates a plane mesh
  54615. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54616. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54617. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54619. * * 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
  54620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54621. * @param name defines the name of the mesh
  54622. * @param options defines the options used to create the mesh
  54623. * @param scene defines the hosting scene
  54624. * @returns the plane mesh
  54625. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54626. */
  54627. static CreatePlane(name: string, options: {
  54628. size?: number;
  54629. width?: number;
  54630. height?: number;
  54631. sideOrientation?: number;
  54632. frontUVs?: Vector4;
  54633. backUVs?: Vector4;
  54634. updatable?: boolean;
  54635. sourcePlane?: Plane;
  54636. }, scene?: Nullable<Scene>): Mesh;
  54637. /**
  54638. * Creates a ground mesh
  54639. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54640. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54642. * @param name defines the name of the mesh
  54643. * @param options defines the options used to create the mesh
  54644. * @param scene defines the hosting scene
  54645. * @returns the ground mesh
  54646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54647. */
  54648. static CreateGround(name: string, options: {
  54649. width?: number;
  54650. height?: number;
  54651. subdivisions?: number;
  54652. subdivisionsX?: number;
  54653. subdivisionsY?: number;
  54654. updatable?: boolean;
  54655. }, scene?: Nullable<Scene>): Mesh;
  54656. /**
  54657. * Creates a tiled ground mesh
  54658. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54659. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54660. * * 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
  54661. * * 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
  54662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54663. * @param name defines the name of the mesh
  54664. * @param options defines the options used to create the mesh
  54665. * @param scene defines the hosting scene
  54666. * @returns the tiled ground mesh
  54667. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54668. */
  54669. static CreateTiledGround(name: string, options: {
  54670. xmin: number;
  54671. zmin: number;
  54672. xmax: number;
  54673. zmax: number;
  54674. subdivisions?: {
  54675. w: number;
  54676. h: number;
  54677. };
  54678. precision?: {
  54679. w: number;
  54680. h: number;
  54681. };
  54682. updatable?: boolean;
  54683. }, scene?: Nullable<Scene>): Mesh;
  54684. /**
  54685. * Creates a ground mesh from a height map
  54686. * * The parameter `url` sets the URL of the height map image resource.
  54687. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54688. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54689. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54690. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54691. * * 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.
  54692. * * 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).
  54693. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54695. * @param name defines the name of the mesh
  54696. * @param url defines the url to the height map
  54697. * @param options defines the options used to create the mesh
  54698. * @param scene defines the hosting scene
  54699. * @returns the ground mesh
  54700. * @see https://doc.babylonjs.com/babylon101/height_map
  54701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54702. */
  54703. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54704. width?: number;
  54705. height?: number;
  54706. subdivisions?: number;
  54707. minHeight?: number;
  54708. maxHeight?: number;
  54709. colorFilter?: Color3;
  54710. alphaFilter?: number;
  54711. updatable?: boolean;
  54712. onReady?: (mesh: GroundMesh) => void;
  54713. }, scene?: Nullable<Scene>): GroundMesh;
  54714. /**
  54715. * Creates a polygon mesh
  54716. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54717. * * 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
  54718. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54720. * * 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)
  54721. * * Remember you can only change the shape positions, not their number when updating a polygon
  54722. * @param name defines the name of the mesh
  54723. * @param options defines the options used to create the mesh
  54724. * @param scene defines the hosting scene
  54725. * @param earcutInjection can be used to inject your own earcut reference
  54726. * @returns the polygon mesh
  54727. */
  54728. static CreatePolygon(name: string, options: {
  54729. shape: Vector3[];
  54730. holes?: Vector3[][];
  54731. depth?: number;
  54732. faceUV?: Vector4[];
  54733. faceColors?: Color4[];
  54734. updatable?: boolean;
  54735. sideOrientation?: number;
  54736. frontUVs?: Vector4;
  54737. backUVs?: Vector4;
  54738. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54739. /**
  54740. * Creates an extruded polygon mesh, with depth in the Y direction.
  54741. * * 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)
  54742. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54743. * @param name defines the name of the mesh
  54744. * @param options defines the options used to create the mesh
  54745. * @param scene defines the hosting scene
  54746. * @param earcutInjection can be used to inject your own earcut reference
  54747. * @returns the polygon mesh
  54748. */
  54749. static ExtrudePolygon(name: string, options: {
  54750. shape: Vector3[];
  54751. holes?: Vector3[][];
  54752. depth?: number;
  54753. faceUV?: Vector4[];
  54754. faceColors?: Color4[];
  54755. updatable?: boolean;
  54756. sideOrientation?: number;
  54757. frontUVs?: Vector4;
  54758. backUVs?: Vector4;
  54759. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54760. /**
  54761. * Creates a tube mesh.
  54762. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54763. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54764. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54765. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54766. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54767. * * 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)
  54768. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54769. * * 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
  54770. * * 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
  54771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54772. * * 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
  54773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54775. * @param name defines the name of the mesh
  54776. * @param options defines the options used to create the mesh
  54777. * @param scene defines the hosting scene
  54778. * @returns the tube mesh
  54779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54780. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54781. */
  54782. static CreateTube(name: string, options: {
  54783. path: Vector3[];
  54784. radius?: number;
  54785. tessellation?: number;
  54786. radiusFunction?: {
  54787. (i: number, distance: number): number;
  54788. };
  54789. cap?: number;
  54790. arc?: number;
  54791. updatable?: boolean;
  54792. sideOrientation?: number;
  54793. frontUVs?: Vector4;
  54794. backUVs?: Vector4;
  54795. instance?: Mesh;
  54796. invertUV?: boolean;
  54797. }, scene?: Nullable<Scene>): Mesh;
  54798. /**
  54799. * Creates a polyhedron mesh
  54800. * * 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
  54801. * * The parameter `size` (positive float, default 1) sets the polygon size
  54802. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54803. * * 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`
  54804. * * 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
  54805. * * 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)`)
  54806. * * 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
  54807. * * 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
  54808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54809. * * 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
  54810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54811. * @param name defines the name of the mesh
  54812. * @param options defines the options used to create the mesh
  54813. * @param scene defines the hosting scene
  54814. * @returns the polyhedron mesh
  54815. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54816. */
  54817. static CreatePolyhedron(name: string, options: {
  54818. type?: number;
  54819. size?: number;
  54820. sizeX?: number;
  54821. sizeY?: number;
  54822. sizeZ?: number;
  54823. custom?: any;
  54824. faceUV?: Vector4[];
  54825. faceColors?: Color4[];
  54826. flat?: boolean;
  54827. updatable?: boolean;
  54828. sideOrientation?: number;
  54829. frontUVs?: Vector4;
  54830. backUVs?: Vector4;
  54831. }, scene?: Nullable<Scene>): Mesh;
  54832. /**
  54833. * Creates a decal mesh.
  54834. * 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
  54835. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54836. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54837. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54838. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54839. * @param name defines the name of the mesh
  54840. * @param sourceMesh defines the mesh where the decal must be applied
  54841. * @param options defines the options used to create the mesh
  54842. * @param scene defines the hosting scene
  54843. * @returns the decal mesh
  54844. * @see https://doc.babylonjs.com/how_to/decals
  54845. */
  54846. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54847. position?: Vector3;
  54848. normal?: Vector3;
  54849. size?: Vector3;
  54850. angle?: number;
  54851. }): Mesh;
  54852. }
  54853. }
  54854. declare module BABYLON {
  54855. /**
  54856. * A simplifier interface for future simplification implementations
  54857. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54858. */
  54859. export interface ISimplifier {
  54860. /**
  54861. * Simplification of a given mesh according to the given settings.
  54862. * Since this requires computation, it is assumed that the function runs async.
  54863. * @param settings The settings of the simplification, including quality and distance
  54864. * @param successCallback A callback that will be called after the mesh was simplified.
  54865. * @param errorCallback in case of an error, this callback will be called. optional.
  54866. */
  54867. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54868. }
  54869. /**
  54870. * Expected simplification settings.
  54871. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54872. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54873. */
  54874. export interface ISimplificationSettings {
  54875. /**
  54876. * Gets or sets the expected quality
  54877. */
  54878. quality: number;
  54879. /**
  54880. * Gets or sets the distance when this optimized version should be used
  54881. */
  54882. distance: number;
  54883. /**
  54884. * Gets an already optimized mesh
  54885. */
  54886. optimizeMesh?: boolean;
  54887. }
  54888. /**
  54889. * Class used to specify simplification options
  54890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54891. */
  54892. export class SimplificationSettings implements ISimplificationSettings {
  54893. /** expected quality */
  54894. quality: number;
  54895. /** distance when this optimized version should be used */
  54896. distance: number;
  54897. /** already optimized mesh */
  54898. optimizeMesh?: boolean | undefined;
  54899. /**
  54900. * Creates a SimplificationSettings
  54901. * @param quality expected quality
  54902. * @param distance distance when this optimized version should be used
  54903. * @param optimizeMesh already optimized mesh
  54904. */
  54905. constructor(
  54906. /** expected quality */
  54907. quality: number,
  54908. /** distance when this optimized version should be used */
  54909. distance: number,
  54910. /** already optimized mesh */
  54911. optimizeMesh?: boolean | undefined);
  54912. }
  54913. /**
  54914. * Interface used to define a simplification task
  54915. */
  54916. export interface ISimplificationTask {
  54917. /**
  54918. * Array of settings
  54919. */
  54920. settings: Array<ISimplificationSettings>;
  54921. /**
  54922. * Simplification type
  54923. */
  54924. simplificationType: SimplificationType;
  54925. /**
  54926. * Mesh to simplify
  54927. */
  54928. mesh: Mesh;
  54929. /**
  54930. * Callback called on success
  54931. */
  54932. successCallback?: () => void;
  54933. /**
  54934. * Defines if parallel processing can be used
  54935. */
  54936. parallelProcessing: boolean;
  54937. }
  54938. /**
  54939. * Queue used to order the simplification tasks
  54940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54941. */
  54942. export class SimplificationQueue {
  54943. private _simplificationArray;
  54944. /**
  54945. * Gets a boolean indicating that the process is still running
  54946. */
  54947. running: boolean;
  54948. /**
  54949. * Creates a new queue
  54950. */
  54951. constructor();
  54952. /**
  54953. * Adds a new simplification task
  54954. * @param task defines a task to add
  54955. */
  54956. addTask(task: ISimplificationTask): void;
  54957. /**
  54958. * Execute next task
  54959. */
  54960. executeNext(): void;
  54961. /**
  54962. * Execute a simplification task
  54963. * @param task defines the task to run
  54964. */
  54965. runSimplification(task: ISimplificationTask): void;
  54966. private getSimplifier;
  54967. }
  54968. /**
  54969. * The implemented types of simplification
  54970. * At the moment only Quadratic Error Decimation is implemented
  54971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54972. */
  54973. export enum SimplificationType {
  54974. /** Quadratic error decimation */
  54975. QUADRATIC = 0
  54976. }
  54977. }
  54978. declare module BABYLON {
  54979. interface Scene {
  54980. /** @hidden (Backing field) */
  54981. _simplificationQueue: SimplificationQueue;
  54982. /**
  54983. * Gets or sets the simplification queue attached to the scene
  54984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54985. */
  54986. simplificationQueue: SimplificationQueue;
  54987. }
  54988. interface Mesh {
  54989. /**
  54990. * Simplify the mesh according to the given array of settings.
  54991. * Function will return immediately and will simplify async
  54992. * @param settings a collection of simplification settings
  54993. * @param parallelProcessing should all levels calculate parallel or one after the other
  54994. * @param simplificationType the type of simplification to run
  54995. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54996. * @returns the current mesh
  54997. */
  54998. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54999. }
  55000. /**
  55001. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55002. * created in a scene
  55003. */
  55004. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55005. /**
  55006. * The component name helpfull to identify the component in the list of scene components.
  55007. */
  55008. readonly name: string;
  55009. /**
  55010. * The scene the component belongs to.
  55011. */
  55012. scene: Scene;
  55013. /**
  55014. * Creates a new instance of the component for the given scene
  55015. * @param scene Defines the scene to register the component in
  55016. */
  55017. constructor(scene: Scene);
  55018. /**
  55019. * Registers the component in a given scene
  55020. */
  55021. register(): void;
  55022. /**
  55023. * Rebuilds the elements related to this component in case of
  55024. * context lost for instance.
  55025. */
  55026. rebuild(): void;
  55027. /**
  55028. * Disposes the component and the associated ressources
  55029. */
  55030. dispose(): void;
  55031. private _beforeCameraUpdate;
  55032. }
  55033. }
  55034. declare module BABYLON {
  55035. /**
  55036. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55037. */
  55038. export interface INavigationEnginePlugin {
  55039. /**
  55040. * plugin name
  55041. */
  55042. name: string;
  55043. /**
  55044. * Creates a navigation mesh
  55045. * @param meshes array of all the geometry used to compute the navigatio mesh
  55046. * @param parameters bunch of parameters used to filter geometry
  55047. */
  55048. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55049. /**
  55050. * Create a navigation mesh debug mesh
  55051. * @param scene is where the mesh will be added
  55052. * @returns debug display mesh
  55053. */
  55054. createDebugNavMesh(scene: Scene): Mesh;
  55055. /**
  55056. * Get a navigation mesh constrained position, closest to the parameter position
  55057. * @param position world position
  55058. * @returns the closest point to position constrained by the navigation mesh
  55059. */
  55060. getClosestPoint(position: Vector3): Vector3;
  55061. /**
  55062. * Get a navigation mesh constrained position, within a particular radius
  55063. * @param position world position
  55064. * @param maxRadius the maximum distance to the constrained world position
  55065. * @returns the closest point to position constrained by the navigation mesh
  55066. */
  55067. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55068. /**
  55069. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55070. * @param start world position
  55071. * @param end world position
  55072. * @returns array containing world position composing the path
  55073. */
  55074. computePath(start: Vector3, end: Vector3): Vector3[];
  55075. /**
  55076. * If this plugin is supported
  55077. * @returns true if plugin is supported
  55078. */
  55079. isSupported(): boolean;
  55080. /**
  55081. * Create a new Crowd so you can add agents
  55082. * @param maxAgents the maximum agent count in the crowd
  55083. * @param maxAgentRadius the maximum radius an agent can have
  55084. * @param scene to attach the crowd to
  55085. * @returns the crowd you can add agents to
  55086. */
  55087. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55088. /**
  55089. * Release all resources
  55090. */
  55091. dispose(): void;
  55092. }
  55093. /**
  55094. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55095. */
  55096. export interface ICrowd {
  55097. /**
  55098. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55099. * You can attach anything to that node. The node position is updated in the scene update tick.
  55100. * @param pos world position that will be constrained by the navigation mesh
  55101. * @param parameters agent parameters
  55102. * @param transform hooked to the agent that will be update by the scene
  55103. * @returns agent index
  55104. */
  55105. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55106. /**
  55107. * Returns the agent position in world space
  55108. * @param index agent index returned by addAgent
  55109. * @returns world space position
  55110. */
  55111. getAgentPosition(index: number): Vector3;
  55112. /**
  55113. * Gets the agent velocity in world space
  55114. * @param index agent index returned by addAgent
  55115. * @returns world space velocity
  55116. */
  55117. getAgentVelocity(index: number): Vector3;
  55118. /**
  55119. * remove a particular agent previously created
  55120. * @param index agent index returned by addAgent
  55121. */
  55122. removeAgent(index: number): void;
  55123. /**
  55124. * get the list of all agents attached to this crowd
  55125. * @returns list of agent indices
  55126. */
  55127. getAgents(): number[];
  55128. /**
  55129. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55130. * @param deltaTime in seconds
  55131. */
  55132. update(deltaTime: number): void;
  55133. /**
  55134. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55135. * @param index agent index returned by addAgent
  55136. * @param destination targeted world position
  55137. */
  55138. agentGoto(index: number, destination: Vector3): void;
  55139. /**
  55140. * Release all resources
  55141. */
  55142. dispose(): void;
  55143. }
  55144. /**
  55145. * Configures an agent
  55146. */
  55147. export interface IAgentParameters {
  55148. /**
  55149. * Agent radius. [Limit: >= 0]
  55150. */
  55151. radius: number;
  55152. /**
  55153. * Agent height. [Limit: > 0]
  55154. */
  55155. height: number;
  55156. /**
  55157. * Maximum allowed acceleration. [Limit: >= 0]
  55158. */
  55159. maxAcceleration: number;
  55160. /**
  55161. * Maximum allowed speed. [Limit: >= 0]
  55162. */
  55163. maxSpeed: number;
  55164. /**
  55165. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55166. */
  55167. collisionQueryRange: number;
  55168. /**
  55169. * The path visibility optimization range. [Limit: > 0]
  55170. */
  55171. pathOptimizationRange: number;
  55172. /**
  55173. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55174. */
  55175. separationWeight: number;
  55176. }
  55177. /**
  55178. * Configures the navigation mesh creation
  55179. */
  55180. export interface INavMeshParameters {
  55181. /**
  55182. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55183. */
  55184. cs: number;
  55185. /**
  55186. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55187. */
  55188. ch: number;
  55189. /**
  55190. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55191. */
  55192. walkableSlopeAngle: number;
  55193. /**
  55194. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55195. * be considered walkable. [Limit: >= 3] [Units: vx]
  55196. */
  55197. walkableHeight: number;
  55198. /**
  55199. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55200. */
  55201. walkableClimb: number;
  55202. /**
  55203. * The distance to erode/shrink the walkable area of the heightfield away from
  55204. * obstructions. [Limit: >=0] [Units: vx]
  55205. */
  55206. walkableRadius: number;
  55207. /**
  55208. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55209. */
  55210. maxEdgeLen: number;
  55211. /**
  55212. * The maximum distance a simplfied contour's border edges should deviate
  55213. * the original raw contour. [Limit: >=0] [Units: vx]
  55214. */
  55215. maxSimplificationError: number;
  55216. /**
  55217. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55218. */
  55219. minRegionArea: number;
  55220. /**
  55221. * Any regions with a span count smaller than this value will, if possible,
  55222. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55223. */
  55224. mergeRegionArea: number;
  55225. /**
  55226. * The maximum number of vertices allowed for polygons generated during the
  55227. * contour to polygon conversion process. [Limit: >= 3]
  55228. */
  55229. maxVertsPerPoly: number;
  55230. /**
  55231. * Sets the sampling distance to use when generating the detail mesh.
  55232. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55233. */
  55234. detailSampleDist: number;
  55235. /**
  55236. * The maximum distance the detail mesh surface should deviate from heightfield
  55237. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55238. */
  55239. detailSampleMaxError: number;
  55240. }
  55241. }
  55242. declare module BABYLON {
  55243. /**
  55244. * RecastJS navigation plugin
  55245. */
  55246. export class RecastJSPlugin implements INavigationEnginePlugin {
  55247. /**
  55248. * Reference to the Recast library
  55249. */
  55250. bjsRECAST: any;
  55251. /**
  55252. * plugin name
  55253. */
  55254. name: string;
  55255. /**
  55256. * the first navmesh created. We might extend this to support multiple navmeshes
  55257. */
  55258. navMesh: any;
  55259. /**
  55260. * Initializes the recastJS plugin
  55261. * @param recastInjection can be used to inject your own recast reference
  55262. */
  55263. constructor(recastInjection?: any);
  55264. /**
  55265. * Creates a navigation mesh
  55266. * @param meshes array of all the geometry used to compute the navigatio mesh
  55267. * @param parameters bunch of parameters used to filter geometry
  55268. */
  55269. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55270. /**
  55271. * Create a navigation mesh debug mesh
  55272. * @param scene is where the mesh will be added
  55273. * @returns debug display mesh
  55274. */
  55275. createDebugNavMesh(scene: Scene): Mesh;
  55276. /**
  55277. * Get a navigation mesh constrained position, closest to the parameter position
  55278. * @param position world position
  55279. * @returns the closest point to position constrained by the navigation mesh
  55280. */
  55281. getClosestPoint(position: Vector3): Vector3;
  55282. /**
  55283. * Get a navigation mesh constrained position, within a particular radius
  55284. * @param position world position
  55285. * @param maxRadius the maximum distance to the constrained world position
  55286. * @returns the closest point to position constrained by the navigation mesh
  55287. */
  55288. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55289. /**
  55290. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55291. * @param start world position
  55292. * @param end world position
  55293. * @returns array containing world position composing the path
  55294. */
  55295. computePath(start: Vector3, end: Vector3): Vector3[];
  55296. /**
  55297. * Create a new Crowd so you can add agents
  55298. * @param maxAgents the maximum agent count in the crowd
  55299. * @param maxAgentRadius the maximum radius an agent can have
  55300. * @param scene to attach the crowd to
  55301. * @returns the crowd you can add agents to
  55302. */
  55303. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55304. /**
  55305. * Disposes
  55306. */
  55307. dispose(): void;
  55308. /**
  55309. * If this plugin is supported
  55310. * @returns true if plugin is supported
  55311. */
  55312. isSupported(): boolean;
  55313. }
  55314. /**
  55315. * Recast detour crowd implementation
  55316. */
  55317. export class RecastJSCrowd implements ICrowd {
  55318. /**
  55319. * Recast/detour plugin
  55320. */
  55321. bjsRECASTPlugin: RecastJSPlugin;
  55322. /**
  55323. * Link to the detour crowd
  55324. */
  55325. recastCrowd: any;
  55326. /**
  55327. * One transform per agent
  55328. */
  55329. transforms: TransformNode[];
  55330. /**
  55331. * All agents created
  55332. */
  55333. agents: number[];
  55334. /**
  55335. * Link to the scene is kept to unregister the crowd from the scene
  55336. */
  55337. private _scene;
  55338. /**
  55339. * Observer for crowd updates
  55340. */
  55341. private _onBeforeAnimationsObserver;
  55342. /**
  55343. * Constructor
  55344. * @param plugin recastJS plugin
  55345. * @param maxAgents the maximum agent count in the crowd
  55346. * @param maxAgentRadius the maximum radius an agent can have
  55347. * @param scene to attach the crowd to
  55348. * @returns the crowd you can add agents to
  55349. */
  55350. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55351. /**
  55352. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55353. * You can attach anything to that node. The node position is updated in the scene update tick.
  55354. * @param pos world position that will be constrained by the navigation mesh
  55355. * @param parameters agent parameters
  55356. * @param transform hooked to the agent that will be update by the scene
  55357. * @returns agent index
  55358. */
  55359. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55360. /**
  55361. * Returns the agent position in world space
  55362. * @param index agent index returned by addAgent
  55363. * @returns world space position
  55364. */
  55365. getAgentPosition(index: number): Vector3;
  55366. /**
  55367. * Returns the agent velocity in world space
  55368. * @param index agent index returned by addAgent
  55369. * @returns world space velocity
  55370. */
  55371. getAgentVelocity(index: number): Vector3;
  55372. /**
  55373. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55374. * @param index agent index returned by addAgent
  55375. * @param destination targeted world position
  55376. */
  55377. agentGoto(index: number, destination: Vector3): void;
  55378. /**
  55379. * remove a particular agent previously created
  55380. * @param index agent index returned by addAgent
  55381. */
  55382. removeAgent(index: number): void;
  55383. /**
  55384. * get the list of all agents attached to this crowd
  55385. * @returns list of agent indices
  55386. */
  55387. getAgents(): number[];
  55388. /**
  55389. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55390. * @param deltaTime in seconds
  55391. */
  55392. update(deltaTime: number): void;
  55393. /**
  55394. * Release all resources
  55395. */
  55396. dispose(): void;
  55397. }
  55398. }
  55399. declare module BABYLON {
  55400. /**
  55401. * Class used to enable access to IndexedDB
  55402. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55403. */
  55404. export class Database implements IOfflineProvider {
  55405. private _callbackManifestChecked;
  55406. private _currentSceneUrl;
  55407. private _db;
  55408. private _enableSceneOffline;
  55409. private _enableTexturesOffline;
  55410. private _manifestVersionFound;
  55411. private _mustUpdateRessources;
  55412. private _hasReachedQuota;
  55413. private _isSupported;
  55414. private _idbFactory;
  55415. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55416. private static IsUASupportingBlobStorage;
  55417. /**
  55418. * Gets a boolean indicating if Database storate is enabled (off by default)
  55419. */
  55420. static IDBStorageEnabled: boolean;
  55421. /**
  55422. * Gets a boolean indicating if scene must be saved in the database
  55423. */
  55424. readonly enableSceneOffline: boolean;
  55425. /**
  55426. * Gets a boolean indicating if textures must be saved in the database
  55427. */
  55428. readonly enableTexturesOffline: boolean;
  55429. /**
  55430. * Creates a new Database
  55431. * @param urlToScene defines the url to load the scene
  55432. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55433. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55434. */
  55435. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55436. private static _ParseURL;
  55437. private static _ReturnFullUrlLocation;
  55438. private _checkManifestFile;
  55439. /**
  55440. * Open the database and make it available
  55441. * @param successCallback defines the callback to call on success
  55442. * @param errorCallback defines the callback to call on error
  55443. */
  55444. open(successCallback: () => void, errorCallback: () => void): void;
  55445. /**
  55446. * Loads an image from the database
  55447. * @param url defines the url to load from
  55448. * @param image defines the target DOM image
  55449. */
  55450. loadImage(url: string, image: HTMLImageElement): void;
  55451. private _loadImageFromDBAsync;
  55452. private _saveImageIntoDBAsync;
  55453. private _checkVersionFromDB;
  55454. private _loadVersionFromDBAsync;
  55455. private _saveVersionIntoDBAsync;
  55456. /**
  55457. * Loads a file from database
  55458. * @param url defines the URL to load from
  55459. * @param sceneLoaded defines a callback to call on success
  55460. * @param progressCallBack defines a callback to call when progress changed
  55461. * @param errorCallback defines a callback to call on error
  55462. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55463. */
  55464. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55465. private _loadFileAsync;
  55466. private _saveFileAsync;
  55467. /**
  55468. * Validates if xhr data is correct
  55469. * @param xhr defines the request to validate
  55470. * @param dataType defines the expected data type
  55471. * @returns true if data is correct
  55472. */
  55473. private static _ValidateXHRData;
  55474. }
  55475. }
  55476. declare module BABYLON {
  55477. /** @hidden */
  55478. export var gpuUpdateParticlesPixelShader: {
  55479. name: string;
  55480. shader: string;
  55481. };
  55482. }
  55483. declare module BABYLON {
  55484. /** @hidden */
  55485. export var gpuUpdateParticlesVertexShader: {
  55486. name: string;
  55487. shader: string;
  55488. };
  55489. }
  55490. declare module BABYLON {
  55491. /** @hidden */
  55492. export var clipPlaneFragmentDeclaration2: {
  55493. name: string;
  55494. shader: string;
  55495. };
  55496. }
  55497. declare module BABYLON {
  55498. /** @hidden */
  55499. export var gpuRenderParticlesPixelShader: {
  55500. name: string;
  55501. shader: string;
  55502. };
  55503. }
  55504. declare module BABYLON {
  55505. /** @hidden */
  55506. export var clipPlaneVertexDeclaration2: {
  55507. name: string;
  55508. shader: string;
  55509. };
  55510. }
  55511. declare module BABYLON {
  55512. /** @hidden */
  55513. export var gpuRenderParticlesVertexShader: {
  55514. name: string;
  55515. shader: string;
  55516. };
  55517. }
  55518. declare module BABYLON {
  55519. /**
  55520. * This represents a GPU particle system in Babylon
  55521. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55522. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55523. */
  55524. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55525. /**
  55526. * The layer mask we are rendering the particles through.
  55527. */
  55528. layerMask: number;
  55529. private _capacity;
  55530. private _activeCount;
  55531. private _currentActiveCount;
  55532. private _accumulatedCount;
  55533. private _renderEffect;
  55534. private _updateEffect;
  55535. private _buffer0;
  55536. private _buffer1;
  55537. private _spriteBuffer;
  55538. private _updateVAO;
  55539. private _renderVAO;
  55540. private _targetIndex;
  55541. private _sourceBuffer;
  55542. private _targetBuffer;
  55543. private _engine;
  55544. private _currentRenderId;
  55545. private _started;
  55546. private _stopped;
  55547. private _timeDelta;
  55548. private _randomTexture;
  55549. private _randomTexture2;
  55550. private _attributesStrideSize;
  55551. private _updateEffectOptions;
  55552. private _randomTextureSize;
  55553. private _actualFrame;
  55554. private readonly _rawTextureWidth;
  55555. /**
  55556. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55557. */
  55558. static readonly IsSupported: boolean;
  55559. /**
  55560. * An event triggered when the system is disposed.
  55561. */
  55562. onDisposeObservable: Observable<GPUParticleSystem>;
  55563. /**
  55564. * Gets the maximum number of particles active at the same time.
  55565. * @returns The max number of active particles.
  55566. */
  55567. getCapacity(): number;
  55568. /**
  55569. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55570. * to override the particles.
  55571. */
  55572. forceDepthWrite: boolean;
  55573. /**
  55574. * Gets or set the number of active particles
  55575. */
  55576. activeParticleCount: number;
  55577. private _preWarmDone;
  55578. /**
  55579. * Is this system ready to be used/rendered
  55580. * @return true if the system is ready
  55581. */
  55582. isReady(): boolean;
  55583. /**
  55584. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55585. * @returns True if it has been started, otherwise false.
  55586. */
  55587. isStarted(): boolean;
  55588. /**
  55589. * Starts the particle system and begins to emit
  55590. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55591. */
  55592. start(delay?: number): void;
  55593. /**
  55594. * Stops the particle system.
  55595. */
  55596. stop(): void;
  55597. /**
  55598. * Remove all active particles
  55599. */
  55600. reset(): void;
  55601. /**
  55602. * Returns the string "GPUParticleSystem"
  55603. * @returns a string containing the class name
  55604. */
  55605. getClassName(): string;
  55606. private _colorGradientsTexture;
  55607. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55608. /**
  55609. * Adds a new color gradient
  55610. * @param gradient defines the gradient to use (between 0 and 1)
  55611. * @param color1 defines the color to affect to the specified gradient
  55612. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55613. * @returns the current particle system
  55614. */
  55615. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55616. /**
  55617. * Remove a specific color gradient
  55618. * @param gradient defines the gradient to remove
  55619. * @returns the current particle system
  55620. */
  55621. removeColorGradient(gradient: number): GPUParticleSystem;
  55622. private _angularSpeedGradientsTexture;
  55623. private _sizeGradientsTexture;
  55624. private _velocityGradientsTexture;
  55625. private _limitVelocityGradientsTexture;
  55626. private _dragGradientsTexture;
  55627. private _addFactorGradient;
  55628. /**
  55629. * Adds a new size gradient
  55630. * @param gradient defines the gradient to use (between 0 and 1)
  55631. * @param factor defines the size factor to affect to the specified gradient
  55632. * @returns the current particle system
  55633. */
  55634. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55635. /**
  55636. * Remove a specific size gradient
  55637. * @param gradient defines the gradient to remove
  55638. * @returns the current particle system
  55639. */
  55640. removeSizeGradient(gradient: number): GPUParticleSystem;
  55641. /**
  55642. * Adds a new angular speed gradient
  55643. * @param gradient defines the gradient to use (between 0 and 1)
  55644. * @param factor defines the angular speed to affect to the specified gradient
  55645. * @returns the current particle system
  55646. */
  55647. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55648. /**
  55649. * Remove a specific angular speed gradient
  55650. * @param gradient defines the gradient to remove
  55651. * @returns the current particle system
  55652. */
  55653. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55654. /**
  55655. * Adds a new velocity gradient
  55656. * @param gradient defines the gradient to use (between 0 and 1)
  55657. * @param factor defines the velocity to affect to the specified gradient
  55658. * @returns the current particle system
  55659. */
  55660. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55661. /**
  55662. * Remove a specific velocity gradient
  55663. * @param gradient defines the gradient to remove
  55664. * @returns the current particle system
  55665. */
  55666. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55667. /**
  55668. * Adds a new limit velocity gradient
  55669. * @param gradient defines the gradient to use (between 0 and 1)
  55670. * @param factor defines the limit velocity value to affect to the specified gradient
  55671. * @returns the current particle system
  55672. */
  55673. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55674. /**
  55675. * Remove a specific limit velocity gradient
  55676. * @param gradient defines the gradient to remove
  55677. * @returns the current particle system
  55678. */
  55679. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55680. /**
  55681. * Adds a new drag gradient
  55682. * @param gradient defines the gradient to use (between 0 and 1)
  55683. * @param factor defines the drag value to affect to the specified gradient
  55684. * @returns the current particle system
  55685. */
  55686. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55687. /**
  55688. * Remove a specific drag gradient
  55689. * @param gradient defines the gradient to remove
  55690. * @returns the current particle system
  55691. */
  55692. removeDragGradient(gradient: number): GPUParticleSystem;
  55693. /**
  55694. * Not supported by GPUParticleSystem
  55695. * @param gradient defines the gradient to use (between 0 and 1)
  55696. * @param factor defines the emit rate value to affect to the specified gradient
  55697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55698. * @returns the current particle system
  55699. */
  55700. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55701. /**
  55702. * Not supported by GPUParticleSystem
  55703. * @param gradient defines the gradient to remove
  55704. * @returns the current particle system
  55705. */
  55706. removeEmitRateGradient(gradient: number): IParticleSystem;
  55707. /**
  55708. * Not supported by GPUParticleSystem
  55709. * @param gradient defines the gradient to use (between 0 and 1)
  55710. * @param factor defines the start size value to affect to the specified gradient
  55711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55712. * @returns the current particle system
  55713. */
  55714. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55715. /**
  55716. * Not supported by GPUParticleSystem
  55717. * @param gradient defines the gradient to remove
  55718. * @returns the current particle system
  55719. */
  55720. removeStartSizeGradient(gradient: number): IParticleSystem;
  55721. /**
  55722. * Not supported by GPUParticleSystem
  55723. * @param gradient defines the gradient to use (between 0 and 1)
  55724. * @param min defines the color remap minimal range
  55725. * @param max defines the color remap maximal range
  55726. * @returns the current particle system
  55727. */
  55728. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55729. /**
  55730. * Not supported by GPUParticleSystem
  55731. * @param gradient defines the gradient to remove
  55732. * @returns the current particle system
  55733. */
  55734. removeColorRemapGradient(): IParticleSystem;
  55735. /**
  55736. * Not supported by GPUParticleSystem
  55737. * @param gradient defines the gradient to use (between 0 and 1)
  55738. * @param min defines the alpha remap minimal range
  55739. * @param max defines the alpha remap maximal range
  55740. * @returns the current particle system
  55741. */
  55742. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55743. /**
  55744. * Not supported by GPUParticleSystem
  55745. * @param gradient defines the gradient to remove
  55746. * @returns the current particle system
  55747. */
  55748. removeAlphaRemapGradient(): IParticleSystem;
  55749. /**
  55750. * Not supported by GPUParticleSystem
  55751. * @param gradient defines the gradient to use (between 0 and 1)
  55752. * @param color defines the color to affect to the specified gradient
  55753. * @returns the current particle system
  55754. */
  55755. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55756. /**
  55757. * Not supported by GPUParticleSystem
  55758. * @param gradient defines the gradient to remove
  55759. * @returns the current particle system
  55760. */
  55761. removeRampGradient(): IParticleSystem;
  55762. /**
  55763. * Not supported by GPUParticleSystem
  55764. * @returns the list of ramp gradients
  55765. */
  55766. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55767. /**
  55768. * Not supported by GPUParticleSystem
  55769. * Gets or sets a boolean indicating that ramp gradients must be used
  55770. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55771. */
  55772. useRampGradients: boolean;
  55773. /**
  55774. * Not supported by GPUParticleSystem
  55775. * @param gradient defines the gradient to use (between 0 and 1)
  55776. * @param factor defines the life time factor to affect to the specified gradient
  55777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55778. * @returns the current particle system
  55779. */
  55780. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55781. /**
  55782. * Not supported by GPUParticleSystem
  55783. * @param gradient defines the gradient to remove
  55784. * @returns the current particle system
  55785. */
  55786. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55787. /**
  55788. * Instantiates a GPU particle system.
  55789. * 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.
  55790. * @param name The name of the particle system
  55791. * @param options The options used to create the system
  55792. * @param scene The scene the particle system belongs to
  55793. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55794. */
  55795. constructor(name: string, options: Partial<{
  55796. capacity: number;
  55797. randomTextureSize: number;
  55798. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55799. protected _reset(): void;
  55800. private _createUpdateVAO;
  55801. private _createRenderVAO;
  55802. private _initialize;
  55803. /** @hidden */
  55804. _recreateUpdateEffect(): void;
  55805. /** @hidden */
  55806. _recreateRenderEffect(): void;
  55807. /**
  55808. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55809. * @param preWarm defines if we are in the pre-warmimg phase
  55810. */
  55811. animate(preWarm?: boolean): void;
  55812. private _createFactorGradientTexture;
  55813. private _createSizeGradientTexture;
  55814. private _createAngularSpeedGradientTexture;
  55815. private _createVelocityGradientTexture;
  55816. private _createLimitVelocityGradientTexture;
  55817. private _createDragGradientTexture;
  55818. private _createColorGradientTexture;
  55819. /**
  55820. * Renders the particle system in its current state
  55821. * @param preWarm defines if the system should only update the particles but not render them
  55822. * @returns the current number of particles
  55823. */
  55824. render(preWarm?: boolean): number;
  55825. /**
  55826. * Rebuilds the particle system
  55827. */
  55828. rebuild(): void;
  55829. private _releaseBuffers;
  55830. private _releaseVAOs;
  55831. /**
  55832. * Disposes the particle system and free the associated resources
  55833. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55834. */
  55835. dispose(disposeTexture?: boolean): void;
  55836. /**
  55837. * Clones the particle system.
  55838. * @param name The name of the cloned object
  55839. * @param newEmitter The new emitter to use
  55840. * @returns the cloned particle system
  55841. */
  55842. clone(name: string, newEmitter: any): GPUParticleSystem;
  55843. /**
  55844. * Serializes the particle system to a JSON object.
  55845. * @returns the JSON object
  55846. */
  55847. serialize(): any;
  55848. /**
  55849. * Parses a JSON object to create a GPU particle system.
  55850. * @param parsedParticleSystem The JSON object to parse
  55851. * @param scene The scene to create the particle system in
  55852. * @param rootUrl The root url to use to load external dependencies like texture
  55853. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55854. * @returns the parsed GPU particle system
  55855. */
  55856. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55857. }
  55858. }
  55859. declare module BABYLON {
  55860. /**
  55861. * Represents a set of particle systems working together to create a specific effect
  55862. */
  55863. export class ParticleSystemSet implements IDisposable {
  55864. private _emitterCreationOptions;
  55865. private _emitterNode;
  55866. /**
  55867. * Gets the particle system list
  55868. */
  55869. systems: IParticleSystem[];
  55870. /**
  55871. * Gets the emitter node used with this set
  55872. */
  55873. readonly emitterNode: Nullable<TransformNode>;
  55874. /**
  55875. * Creates a new emitter mesh as a sphere
  55876. * @param options defines the options used to create the sphere
  55877. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  55878. * @param scene defines the hosting scene
  55879. */
  55880. setEmitterAsSphere(options: {
  55881. diameter: number;
  55882. segments: number;
  55883. color: Color3;
  55884. }, renderingGroupId: number, scene: Scene): void;
  55885. /**
  55886. * Starts all particle systems of the set
  55887. * @param emitter defines an optional mesh to use as emitter for the particle systems
  55888. */
  55889. start(emitter?: AbstractMesh): void;
  55890. /**
  55891. * Release all associated resources
  55892. */
  55893. dispose(): void;
  55894. /**
  55895. * Serialize the set into a JSON compatible object
  55896. * @returns a JSON compatible representation of the set
  55897. */
  55898. serialize(): any;
  55899. /**
  55900. * Parse a new ParticleSystemSet from a serialized source
  55901. * @param data defines a JSON compatible representation of the set
  55902. * @param scene defines the hosting scene
  55903. * @param gpu defines if we want GPU particles or CPU particles
  55904. * @returns a new ParticleSystemSet
  55905. */
  55906. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  55907. }
  55908. }
  55909. declare module BABYLON {
  55910. /**
  55911. * This class is made for on one-liner static method to help creating particle system set.
  55912. */
  55913. export class ParticleHelper {
  55914. /**
  55915. * Gets or sets base Assets URL
  55916. */
  55917. static BaseAssetsUrl: string;
  55918. /**
  55919. * Create a default particle system that you can tweak
  55920. * @param emitter defines the emitter to use
  55921. * @param capacity defines the system capacity (default is 500 particles)
  55922. * @param scene defines the hosting scene
  55923. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  55924. * @returns the new Particle system
  55925. */
  55926. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  55927. /**
  55928. * This is the main static method (one-liner) of this helper to create different particle systems
  55929. * @param type This string represents the type to the particle system to create
  55930. * @param scene The scene where the particle system should live
  55931. * @param gpu If the system will use gpu
  55932. * @returns the ParticleSystemSet created
  55933. */
  55934. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  55935. /**
  55936. * Static function used to export a particle system to a ParticleSystemSet variable.
  55937. * Please note that the emitter shape is not exported
  55938. * @param systems defines the particle systems to export
  55939. * @returns the created particle system set
  55940. */
  55941. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  55942. }
  55943. }
  55944. declare module BABYLON {
  55945. interface Engine {
  55946. /**
  55947. * Create an effect to use with particle systems.
  55948. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  55949. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  55950. * @param uniformsNames defines a list of attribute names
  55951. * @param samplers defines an array of string used to represent textures
  55952. * @param defines defines the string containing the defines to use to compile the shaders
  55953. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  55954. * @param onCompiled defines a function to call when the effect creation is successful
  55955. * @param onError defines a function to call when the effect creation has failed
  55956. * @returns the new Effect
  55957. */
  55958. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  55959. }
  55960. interface Mesh {
  55961. /**
  55962. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  55963. * @returns an array of IParticleSystem
  55964. */
  55965. getEmittedParticleSystems(): IParticleSystem[];
  55966. /**
  55967. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  55968. * @returns an array of IParticleSystem
  55969. */
  55970. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  55971. }
  55972. /**
  55973. * @hidden
  55974. */
  55975. export var _IDoNeedToBeInTheBuild: number;
  55976. }
  55977. declare module BABYLON {
  55978. interface Scene {
  55979. /** @hidden (Backing field) */
  55980. _physicsEngine: Nullable<IPhysicsEngine>;
  55981. /**
  55982. * Gets the current physics engine
  55983. * @returns a IPhysicsEngine or null if none attached
  55984. */
  55985. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  55986. /**
  55987. * Enables physics to the current scene
  55988. * @param gravity defines the scene's gravity for the physics engine
  55989. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55990. * @return a boolean indicating if the physics engine was initialized
  55991. */
  55992. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55993. /**
  55994. * Disables and disposes the physics engine associated with the scene
  55995. */
  55996. disablePhysicsEngine(): void;
  55997. /**
  55998. * Gets a boolean indicating if there is an active physics engine
  55999. * @returns a boolean indicating if there is an active physics engine
  56000. */
  56001. isPhysicsEnabled(): boolean;
  56002. /**
  56003. * Deletes a physics compound impostor
  56004. * @param compound defines the compound to delete
  56005. */
  56006. deleteCompoundImpostor(compound: any): void;
  56007. /**
  56008. * An event triggered when physic simulation is about to be run
  56009. */
  56010. onBeforePhysicsObservable: Observable<Scene>;
  56011. /**
  56012. * An event triggered when physic simulation has been done
  56013. */
  56014. onAfterPhysicsObservable: Observable<Scene>;
  56015. }
  56016. interface AbstractMesh {
  56017. /** @hidden */
  56018. _physicsImpostor: Nullable<PhysicsImpostor>;
  56019. /**
  56020. * Gets or sets impostor used for physic simulation
  56021. * @see http://doc.babylonjs.com/features/physics_engine
  56022. */
  56023. physicsImpostor: Nullable<PhysicsImpostor>;
  56024. /**
  56025. * Gets the current physics impostor
  56026. * @see http://doc.babylonjs.com/features/physics_engine
  56027. * @returns a physics impostor or null
  56028. */
  56029. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56030. /** Apply a physic impulse to the mesh
  56031. * @param force defines the force to apply
  56032. * @param contactPoint defines where to apply the force
  56033. * @returns the current mesh
  56034. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56035. */
  56036. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56037. /**
  56038. * Creates a physic joint between two meshes
  56039. * @param otherMesh defines the other mesh to use
  56040. * @param pivot1 defines the pivot to use on this mesh
  56041. * @param pivot2 defines the pivot to use on the other mesh
  56042. * @param options defines additional options (can be plugin dependent)
  56043. * @returns the current mesh
  56044. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56045. */
  56046. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56047. /** @hidden */
  56048. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56049. }
  56050. /**
  56051. * Defines the physics engine scene component responsible to manage a physics engine
  56052. */
  56053. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56054. /**
  56055. * The component name helpful to identify the component in the list of scene components.
  56056. */
  56057. readonly name: string;
  56058. /**
  56059. * The scene the component belongs to.
  56060. */
  56061. scene: Scene;
  56062. /**
  56063. * Creates a new instance of the component for the given scene
  56064. * @param scene Defines the scene to register the component in
  56065. */
  56066. constructor(scene: Scene);
  56067. /**
  56068. * Registers the component in a given scene
  56069. */
  56070. register(): void;
  56071. /**
  56072. * Rebuilds the elements related to this component in case of
  56073. * context lost for instance.
  56074. */
  56075. rebuild(): void;
  56076. /**
  56077. * Disposes the component and the associated ressources
  56078. */
  56079. dispose(): void;
  56080. }
  56081. }
  56082. declare module BABYLON {
  56083. /**
  56084. * A helper for physics simulations
  56085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56086. */
  56087. export class PhysicsHelper {
  56088. private _scene;
  56089. private _physicsEngine;
  56090. /**
  56091. * Initializes the Physics helper
  56092. * @param scene Babylon.js scene
  56093. */
  56094. constructor(scene: Scene);
  56095. /**
  56096. * Applies a radial explosion impulse
  56097. * @param origin the origin of the explosion
  56098. * @param radiusOrEventOptions the radius or the options of radial explosion
  56099. * @param strength the explosion strength
  56100. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56101. * @returns A physics radial explosion event, or null
  56102. */
  56103. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56104. /**
  56105. * Applies a radial explosion force
  56106. * @param origin the origin of the explosion
  56107. * @param radiusOrEventOptions the radius or the options of radial explosion
  56108. * @param strength the explosion strength
  56109. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56110. * @returns A physics radial explosion event, or null
  56111. */
  56112. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56113. /**
  56114. * Creates a gravitational field
  56115. * @param origin the origin of the explosion
  56116. * @param radiusOrEventOptions the radius or the options of radial explosion
  56117. * @param strength the explosion strength
  56118. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56119. * @returns A physics gravitational field event, or null
  56120. */
  56121. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56122. /**
  56123. * Creates a physics updraft event
  56124. * @param origin the origin of the updraft
  56125. * @param radiusOrEventOptions the radius or the options of the updraft
  56126. * @param strength the strength of the updraft
  56127. * @param height the height of the updraft
  56128. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56129. * @returns A physics updraft event, or null
  56130. */
  56131. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56132. /**
  56133. * Creates a physics vortex event
  56134. * @param origin the of the vortex
  56135. * @param radiusOrEventOptions the radius or the options of the vortex
  56136. * @param strength the strength of the vortex
  56137. * @param height the height of the vortex
  56138. * @returns a Physics vortex event, or null
  56139. * A physics vortex event or null
  56140. */
  56141. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56142. }
  56143. /**
  56144. * Represents a physics radial explosion event
  56145. */
  56146. class PhysicsRadialExplosionEvent {
  56147. private _scene;
  56148. private _options;
  56149. private _sphere;
  56150. private _dataFetched;
  56151. /**
  56152. * Initializes a radial explosioin event
  56153. * @param _scene BabylonJS scene
  56154. * @param _options The options for the vortex event
  56155. */
  56156. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56157. /**
  56158. * Returns the data related to the radial explosion event (sphere).
  56159. * @returns The radial explosion event data
  56160. */
  56161. getData(): PhysicsRadialExplosionEventData;
  56162. /**
  56163. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56164. * @param impostor A physics imposter
  56165. * @param origin the origin of the explosion
  56166. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56167. */
  56168. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56169. /**
  56170. * Triggers affecterd impostors callbacks
  56171. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56172. */
  56173. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56174. /**
  56175. * Disposes the sphere.
  56176. * @param force Specifies if the sphere should be disposed by force
  56177. */
  56178. dispose(force?: boolean): void;
  56179. /*** Helpers ***/
  56180. private _prepareSphere;
  56181. private _intersectsWithSphere;
  56182. }
  56183. /**
  56184. * Represents a gravitational field event
  56185. */
  56186. class PhysicsGravitationalFieldEvent {
  56187. private _physicsHelper;
  56188. private _scene;
  56189. private _origin;
  56190. private _options;
  56191. private _tickCallback;
  56192. private _sphere;
  56193. private _dataFetched;
  56194. /**
  56195. * Initializes the physics gravitational field event
  56196. * @param _physicsHelper A physics helper
  56197. * @param _scene BabylonJS scene
  56198. * @param _origin The origin position of the gravitational field event
  56199. * @param _options The options for the vortex event
  56200. */
  56201. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56202. /**
  56203. * Returns the data related to the gravitational field event (sphere).
  56204. * @returns A gravitational field event
  56205. */
  56206. getData(): PhysicsGravitationalFieldEventData;
  56207. /**
  56208. * Enables the gravitational field.
  56209. */
  56210. enable(): void;
  56211. /**
  56212. * Disables the gravitational field.
  56213. */
  56214. disable(): void;
  56215. /**
  56216. * Disposes the sphere.
  56217. * @param force The force to dispose from the gravitational field event
  56218. */
  56219. dispose(force?: boolean): void;
  56220. private _tick;
  56221. }
  56222. /**
  56223. * Represents a physics updraft event
  56224. */
  56225. class PhysicsUpdraftEvent {
  56226. private _scene;
  56227. private _origin;
  56228. private _options;
  56229. private _physicsEngine;
  56230. private _originTop;
  56231. private _originDirection;
  56232. private _tickCallback;
  56233. private _cylinder;
  56234. private _cylinderPosition;
  56235. private _dataFetched;
  56236. /**
  56237. * Initializes the physics updraft event
  56238. * @param _scene BabylonJS scene
  56239. * @param _origin The origin position of the updraft
  56240. * @param _options The options for the updraft event
  56241. */
  56242. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56243. /**
  56244. * Returns the data related to the updraft event (cylinder).
  56245. * @returns A physics updraft event
  56246. */
  56247. getData(): PhysicsUpdraftEventData;
  56248. /**
  56249. * Enables the updraft.
  56250. */
  56251. enable(): void;
  56252. /**
  56253. * Disables the updraft.
  56254. */
  56255. disable(): void;
  56256. /**
  56257. * Disposes the cylinder.
  56258. * @param force Specifies if the updraft should be disposed by force
  56259. */
  56260. dispose(force?: boolean): void;
  56261. private getImpostorHitData;
  56262. private _tick;
  56263. /*** Helpers ***/
  56264. private _prepareCylinder;
  56265. private _intersectsWithCylinder;
  56266. }
  56267. /**
  56268. * Represents a physics vortex event
  56269. */
  56270. class PhysicsVortexEvent {
  56271. private _scene;
  56272. private _origin;
  56273. private _options;
  56274. private _physicsEngine;
  56275. private _originTop;
  56276. private _tickCallback;
  56277. private _cylinder;
  56278. private _cylinderPosition;
  56279. private _dataFetched;
  56280. /**
  56281. * Initializes the physics vortex event
  56282. * @param _scene The BabylonJS scene
  56283. * @param _origin The origin position of the vortex
  56284. * @param _options The options for the vortex event
  56285. */
  56286. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56287. /**
  56288. * Returns the data related to the vortex event (cylinder).
  56289. * @returns The physics vortex event data
  56290. */
  56291. getData(): PhysicsVortexEventData;
  56292. /**
  56293. * Enables the vortex.
  56294. */
  56295. enable(): void;
  56296. /**
  56297. * Disables the cortex.
  56298. */
  56299. disable(): void;
  56300. /**
  56301. * Disposes the sphere.
  56302. * @param force
  56303. */
  56304. dispose(force?: boolean): void;
  56305. private getImpostorHitData;
  56306. private _tick;
  56307. /*** Helpers ***/
  56308. private _prepareCylinder;
  56309. private _intersectsWithCylinder;
  56310. }
  56311. /**
  56312. * Options fot the radial explosion event
  56313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56314. */
  56315. export class PhysicsRadialExplosionEventOptions {
  56316. /**
  56317. * The radius of the sphere for the radial explosion.
  56318. */
  56319. radius: number;
  56320. /**
  56321. * The strenth of the explosion.
  56322. */
  56323. strength: number;
  56324. /**
  56325. * The strenght of the force in correspondence to the distance of the affected object
  56326. */
  56327. falloff: PhysicsRadialImpulseFalloff;
  56328. /**
  56329. * Sphere options for the radial explosion.
  56330. */
  56331. sphere: {
  56332. segments: number;
  56333. diameter: number;
  56334. };
  56335. /**
  56336. * Sphere options for the radial explosion.
  56337. */
  56338. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56339. }
  56340. /**
  56341. * Options fot the updraft event
  56342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56343. */
  56344. export class PhysicsUpdraftEventOptions {
  56345. /**
  56346. * The radius of the cylinder for the vortex
  56347. */
  56348. radius: number;
  56349. /**
  56350. * The strenth of the updraft.
  56351. */
  56352. strength: number;
  56353. /**
  56354. * The height of the cylinder for the updraft.
  56355. */
  56356. height: number;
  56357. /**
  56358. * The mode for the the updraft.
  56359. */
  56360. updraftMode: PhysicsUpdraftMode;
  56361. }
  56362. /**
  56363. * Options fot the vortex event
  56364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56365. */
  56366. export class PhysicsVortexEventOptions {
  56367. /**
  56368. * The radius of the cylinder for the vortex
  56369. */
  56370. radius: number;
  56371. /**
  56372. * The strenth of the vortex.
  56373. */
  56374. strength: number;
  56375. /**
  56376. * The height of the cylinder for the vortex.
  56377. */
  56378. height: number;
  56379. /**
  56380. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56381. */
  56382. centripetalForceThreshold: number;
  56383. /**
  56384. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56385. */
  56386. centripetalForceMultiplier: number;
  56387. /**
  56388. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56389. */
  56390. centrifugalForceMultiplier: number;
  56391. /**
  56392. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56393. */
  56394. updraftForceMultiplier: number;
  56395. }
  56396. /**
  56397. * The strenght of the force in correspondence to the distance of the affected object
  56398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56399. */
  56400. export enum PhysicsRadialImpulseFalloff {
  56401. /** Defines that impulse is constant in strength across it's whole radius */
  56402. Constant = 0,
  56403. /** Defines that impulse gets weaker if it's further from the origin */
  56404. Linear = 1
  56405. }
  56406. /**
  56407. * The strength of the force in correspondence to the distance of the affected object
  56408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56409. */
  56410. export enum PhysicsUpdraftMode {
  56411. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56412. Center = 0,
  56413. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56414. Perpendicular = 1
  56415. }
  56416. /**
  56417. * Interface for a physics hit data
  56418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56419. */
  56420. export interface PhysicsHitData {
  56421. /**
  56422. * The force applied at the contact point
  56423. */
  56424. force: Vector3;
  56425. /**
  56426. * The contact point
  56427. */
  56428. contactPoint: Vector3;
  56429. /**
  56430. * The distance from the origin to the contact point
  56431. */
  56432. distanceFromOrigin: number;
  56433. }
  56434. /**
  56435. * Interface for radial explosion event data
  56436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56437. */
  56438. export interface PhysicsRadialExplosionEventData {
  56439. /**
  56440. * A sphere used for the radial explosion event
  56441. */
  56442. sphere: Mesh;
  56443. }
  56444. /**
  56445. * Interface for gravitational field event data
  56446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56447. */
  56448. export interface PhysicsGravitationalFieldEventData {
  56449. /**
  56450. * A sphere mesh used for the gravitational field event
  56451. */
  56452. sphere: Mesh;
  56453. }
  56454. /**
  56455. * Interface for updraft event data
  56456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56457. */
  56458. export interface PhysicsUpdraftEventData {
  56459. /**
  56460. * A cylinder used for the updraft event
  56461. */
  56462. cylinder: Mesh;
  56463. }
  56464. /**
  56465. * Interface for vortex event data
  56466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56467. */
  56468. export interface PhysicsVortexEventData {
  56469. /**
  56470. * A cylinder used for the vortex event
  56471. */
  56472. cylinder: Mesh;
  56473. }
  56474. /**
  56475. * Interface for an affected physics impostor
  56476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56477. */
  56478. export interface PhysicsAffectedImpostorWithData {
  56479. /**
  56480. * The impostor affected by the effect
  56481. */
  56482. impostor: PhysicsImpostor;
  56483. /**
  56484. * The data about the hit/horce from the explosion
  56485. */
  56486. hitData: PhysicsHitData;
  56487. }
  56488. }
  56489. declare module BABYLON {
  56490. /** @hidden */
  56491. export var blackAndWhitePixelShader: {
  56492. name: string;
  56493. shader: string;
  56494. };
  56495. }
  56496. declare module BABYLON {
  56497. /**
  56498. * Post process used to render in black and white
  56499. */
  56500. export class BlackAndWhitePostProcess extends PostProcess {
  56501. /**
  56502. * Linear about to convert he result to black and white (default: 1)
  56503. */
  56504. degree: number;
  56505. /**
  56506. * Creates a black and white post process
  56507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56508. * @param name The name of the effect.
  56509. * @param options The required width/height ratio to downsize to before computing the render pass.
  56510. * @param camera The camera to apply the render pass to.
  56511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56512. * @param engine The engine which the post process will be applied. (default: current engine)
  56513. * @param reusable If the post process can be reused on the same frame. (default: false)
  56514. */
  56515. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56516. }
  56517. }
  56518. declare module BABYLON {
  56519. /**
  56520. * This represents a set of one or more post processes in Babylon.
  56521. * A post process can be used to apply a shader to a texture after it is rendered.
  56522. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56523. */
  56524. export class PostProcessRenderEffect {
  56525. private _postProcesses;
  56526. private _getPostProcesses;
  56527. private _singleInstance;
  56528. private _cameras;
  56529. private _indicesForCamera;
  56530. /**
  56531. * Name of the effect
  56532. * @hidden
  56533. */
  56534. _name: string;
  56535. /**
  56536. * Instantiates a post process render effect.
  56537. * A post process can be used to apply a shader to a texture after it is rendered.
  56538. * @param engine The engine the effect is tied to
  56539. * @param name The name of the effect
  56540. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56541. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56542. */
  56543. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56544. /**
  56545. * Checks if all the post processes in the effect are supported.
  56546. */
  56547. readonly isSupported: boolean;
  56548. /**
  56549. * Updates the current state of the effect
  56550. * @hidden
  56551. */
  56552. _update(): void;
  56553. /**
  56554. * Attaches the effect on cameras
  56555. * @param cameras The camera to attach to.
  56556. * @hidden
  56557. */
  56558. _attachCameras(cameras: Camera): void;
  56559. /**
  56560. * Attaches the effect on cameras
  56561. * @param cameras The camera to attach to.
  56562. * @hidden
  56563. */
  56564. _attachCameras(cameras: Camera[]): void;
  56565. /**
  56566. * Detaches the effect on cameras
  56567. * @param cameras The camera to detatch from.
  56568. * @hidden
  56569. */
  56570. _detachCameras(cameras: Camera): void;
  56571. /**
  56572. * Detatches the effect on cameras
  56573. * @param cameras The camera to detatch from.
  56574. * @hidden
  56575. */
  56576. _detachCameras(cameras: Camera[]): void;
  56577. /**
  56578. * Enables the effect on given cameras
  56579. * @param cameras The camera to enable.
  56580. * @hidden
  56581. */
  56582. _enable(cameras: Camera): void;
  56583. /**
  56584. * Enables the effect on given cameras
  56585. * @param cameras The camera to enable.
  56586. * @hidden
  56587. */
  56588. _enable(cameras: Nullable<Camera[]>): void;
  56589. /**
  56590. * Disables the effect on the given cameras
  56591. * @param cameras The camera to disable.
  56592. * @hidden
  56593. */
  56594. _disable(cameras: Camera): void;
  56595. /**
  56596. * Disables the effect on the given cameras
  56597. * @param cameras The camera to disable.
  56598. * @hidden
  56599. */
  56600. _disable(cameras: Nullable<Camera[]>): void;
  56601. /**
  56602. * Gets a list of the post processes contained in the effect.
  56603. * @param camera The camera to get the post processes on.
  56604. * @returns The list of the post processes in the effect.
  56605. */
  56606. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56607. }
  56608. }
  56609. declare module BABYLON {
  56610. /** @hidden */
  56611. export var extractHighlightsPixelShader: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. declare module BABYLON {
  56617. /**
  56618. * 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.
  56619. */
  56620. export class ExtractHighlightsPostProcess extends PostProcess {
  56621. /**
  56622. * The luminance threshold, pixels below this value will be set to black.
  56623. */
  56624. threshold: number;
  56625. /** @hidden */
  56626. _exposure: number;
  56627. /**
  56628. * Post process which has the input texture to be used when performing highlight extraction
  56629. * @hidden
  56630. */
  56631. _inputPostProcess: Nullable<PostProcess>;
  56632. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56633. }
  56634. }
  56635. declare module BABYLON {
  56636. /** @hidden */
  56637. export var bloomMergePixelShader: {
  56638. name: string;
  56639. shader: string;
  56640. };
  56641. }
  56642. declare module BABYLON {
  56643. /**
  56644. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56645. */
  56646. export class BloomMergePostProcess extends PostProcess {
  56647. /** Weight of the bloom to be added to the original input. */
  56648. weight: number;
  56649. /**
  56650. * Creates a new instance of @see BloomMergePostProcess
  56651. * @param name The name of the effect.
  56652. * @param originalFromInput Post process which's input will be used for the merge.
  56653. * @param blurred Blurred highlights post process which's output will be used.
  56654. * @param weight Weight of the bloom to be added to the original input.
  56655. * @param options The required width/height ratio to downsize to before computing the render pass.
  56656. * @param camera The camera to apply the render pass to.
  56657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56658. * @param engine The engine which the post process will be applied. (default: current engine)
  56659. * @param reusable If the post process can be reused on the same frame. (default: false)
  56660. * @param textureType Type of textures used when performing the post process. (default: 0)
  56661. * @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)
  56662. */
  56663. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56664. /** Weight of the bloom to be added to the original input. */
  56665. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56666. }
  56667. }
  56668. declare module BABYLON {
  56669. /**
  56670. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56671. */
  56672. export class BloomEffect extends PostProcessRenderEffect {
  56673. private bloomScale;
  56674. /**
  56675. * @hidden Internal
  56676. */
  56677. _effects: Array<PostProcess>;
  56678. /**
  56679. * @hidden Internal
  56680. */
  56681. _downscale: ExtractHighlightsPostProcess;
  56682. private _blurX;
  56683. private _blurY;
  56684. private _merge;
  56685. /**
  56686. * The luminance threshold to find bright areas of the image to bloom.
  56687. */
  56688. threshold: number;
  56689. /**
  56690. * The strength of the bloom.
  56691. */
  56692. weight: number;
  56693. /**
  56694. * Specifies the size of the bloom blur kernel, relative to the final output size
  56695. */
  56696. kernel: number;
  56697. /**
  56698. * Creates a new instance of @see BloomEffect
  56699. * @param scene The scene the effect belongs to.
  56700. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56701. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56702. * @param bloomWeight The the strength of bloom.
  56703. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56704. * @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)
  56705. */
  56706. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56707. /**
  56708. * Disposes each of the internal effects for a given camera.
  56709. * @param camera The camera to dispose the effect on.
  56710. */
  56711. disposeEffects(camera: Camera): void;
  56712. /**
  56713. * @hidden Internal
  56714. */
  56715. _updateEffects(): void;
  56716. /**
  56717. * Internal
  56718. * @returns if all the contained post processes are ready.
  56719. * @hidden
  56720. */
  56721. _isReady(): boolean;
  56722. }
  56723. }
  56724. declare module BABYLON {
  56725. /** @hidden */
  56726. export var chromaticAberrationPixelShader: {
  56727. name: string;
  56728. shader: string;
  56729. };
  56730. }
  56731. declare module BABYLON {
  56732. /**
  56733. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56734. */
  56735. export class ChromaticAberrationPostProcess extends PostProcess {
  56736. /**
  56737. * The amount of seperation of rgb channels (default: 30)
  56738. */
  56739. aberrationAmount: number;
  56740. /**
  56741. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56742. */
  56743. radialIntensity: number;
  56744. /**
  56745. * 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))
  56746. */
  56747. direction: Vector2;
  56748. /**
  56749. * 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))
  56750. */
  56751. centerPosition: Vector2;
  56752. /**
  56753. * Creates a new instance ChromaticAberrationPostProcess
  56754. * @param name The name of the effect.
  56755. * @param screenWidth The width of the screen to apply the effect on.
  56756. * @param screenHeight The height of the screen to apply the effect on.
  56757. * @param options The required width/height ratio to downsize to before computing the render pass.
  56758. * @param camera The camera to apply the render pass to.
  56759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56760. * @param engine The engine which the post process will be applied. (default: current engine)
  56761. * @param reusable If the post process can be reused on the same frame. (default: false)
  56762. * @param textureType Type of textures used when performing the post process. (default: 0)
  56763. * @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)
  56764. */
  56765. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56766. }
  56767. }
  56768. declare module BABYLON {
  56769. /** @hidden */
  56770. export var circleOfConfusionPixelShader: {
  56771. name: string;
  56772. shader: string;
  56773. };
  56774. }
  56775. declare module BABYLON {
  56776. /**
  56777. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  56778. */
  56779. export class CircleOfConfusionPostProcess extends PostProcess {
  56780. /**
  56781. * 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.
  56782. */
  56783. lensSize: number;
  56784. /**
  56785. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56786. */
  56787. fStop: number;
  56788. /**
  56789. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56790. */
  56791. focusDistance: number;
  56792. /**
  56793. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  56794. */
  56795. focalLength: number;
  56796. private _depthTexture;
  56797. /**
  56798. * Creates a new instance CircleOfConfusionPostProcess
  56799. * @param name The name of the effect.
  56800. * @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.
  56801. * @param options The required width/height ratio to downsize to before computing the render pass.
  56802. * @param camera The camera to apply the render pass to.
  56803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56804. * @param engine The engine which the post process will be applied. (default: current engine)
  56805. * @param reusable If the post process can be reused on the same frame. (default: false)
  56806. * @param textureType Type of textures used when performing the post process. (default: 0)
  56807. * @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)
  56808. */
  56809. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56810. /**
  56811. * 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.
  56812. */
  56813. depthTexture: RenderTargetTexture;
  56814. }
  56815. }
  56816. declare module BABYLON {
  56817. /** @hidden */
  56818. export var colorCorrectionPixelShader: {
  56819. name: string;
  56820. shader: string;
  56821. };
  56822. }
  56823. declare module BABYLON {
  56824. /**
  56825. *
  56826. * This post-process allows the modification of rendered colors by using
  56827. * a 'look-up table' (LUT). This effect is also called Color Grading.
  56828. *
  56829. * The object needs to be provided an url to a texture containing the color
  56830. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  56831. * Use an image editing software to tweak the LUT to match your needs.
  56832. *
  56833. * For an example of a color LUT, see here:
  56834. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  56835. * For explanations on color grading, see here:
  56836. * @see http://udn.epicgames.com/Three/ColorGrading.html
  56837. *
  56838. */
  56839. export class ColorCorrectionPostProcess extends PostProcess {
  56840. private _colorTableTexture;
  56841. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56842. }
  56843. }
  56844. declare module BABYLON {
  56845. /** @hidden */
  56846. export var convolutionPixelShader: {
  56847. name: string;
  56848. shader: string;
  56849. };
  56850. }
  56851. declare module BABYLON {
  56852. /**
  56853. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  56854. * input texture to perform effects such as edge detection or sharpening
  56855. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56856. */
  56857. export class ConvolutionPostProcess extends PostProcess {
  56858. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56859. kernel: number[];
  56860. /**
  56861. * Creates a new instance ConvolutionPostProcess
  56862. * @param name The name of the effect.
  56863. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  56864. * @param options The required width/height ratio to downsize to before computing the render pass.
  56865. * @param camera The camera to apply the render pass to.
  56866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56867. * @param engine The engine which the post process will be applied. (default: current engine)
  56868. * @param reusable If the post process can be reused on the same frame. (default: false)
  56869. * @param textureType Type of textures used when performing the post process. (default: 0)
  56870. */
  56871. constructor(name: string,
  56872. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56873. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56874. /**
  56875. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56876. */
  56877. static EdgeDetect0Kernel: number[];
  56878. /**
  56879. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56880. */
  56881. static EdgeDetect1Kernel: number[];
  56882. /**
  56883. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56884. */
  56885. static EdgeDetect2Kernel: number[];
  56886. /**
  56887. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56888. */
  56889. static SharpenKernel: number[];
  56890. /**
  56891. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56892. */
  56893. static EmbossKernel: number[];
  56894. /**
  56895. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56896. */
  56897. static GaussianKernel: number[];
  56898. }
  56899. }
  56900. declare module BABYLON {
  56901. /**
  56902. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  56903. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  56904. * based on samples that have a large difference in distance than the center pixel.
  56905. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  56906. */
  56907. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  56908. direction: Vector2;
  56909. /**
  56910. * Creates a new instance CircleOfConfusionPostProcess
  56911. * @param name The name of the effect.
  56912. * @param scene The scene the effect belongs to.
  56913. * @param direction The direction the blur should be applied.
  56914. * @param kernel The size of the kernel used to blur.
  56915. * @param options The required width/height ratio to downsize to before computing the render pass.
  56916. * @param camera The camera to apply the render pass to.
  56917. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  56918. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  56919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56920. * @param engine The engine which the post process will be applied. (default: current engine)
  56921. * @param reusable If the post process can be reused on the same frame. (default: false)
  56922. * @param textureType Type of textures used when performing the post process. (default: 0)
  56923. * @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)
  56924. */
  56925. 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);
  56926. }
  56927. }
  56928. declare module BABYLON {
  56929. /** @hidden */
  56930. export var depthOfFieldMergePixelShader: {
  56931. name: string;
  56932. shader: string;
  56933. };
  56934. }
  56935. declare module BABYLON {
  56936. /**
  56937. * Options to be set when merging outputs from the default pipeline.
  56938. */
  56939. export class DepthOfFieldMergePostProcessOptions {
  56940. /**
  56941. * The original image to merge on top of
  56942. */
  56943. originalFromInput: PostProcess;
  56944. /**
  56945. * Parameters to perform the merge of the depth of field effect
  56946. */
  56947. depthOfField?: {
  56948. circleOfConfusion: PostProcess;
  56949. blurSteps: Array<PostProcess>;
  56950. };
  56951. /**
  56952. * Parameters to perform the merge of bloom effect
  56953. */
  56954. bloom?: {
  56955. blurred: PostProcess;
  56956. weight: number;
  56957. };
  56958. }
  56959. /**
  56960. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56961. */
  56962. export class DepthOfFieldMergePostProcess extends PostProcess {
  56963. private blurSteps;
  56964. /**
  56965. * Creates a new instance of DepthOfFieldMergePostProcess
  56966. * @param name The name of the effect.
  56967. * @param originalFromInput Post process which's input will be used for the merge.
  56968. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  56969. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  56970. * @param options The required width/height ratio to downsize to before computing the render pass.
  56971. * @param camera The camera to apply the render pass to.
  56972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56973. * @param engine The engine which the post process will be applied. (default: current engine)
  56974. * @param reusable If the post process can be reused on the same frame. (default: false)
  56975. * @param textureType Type of textures used when performing the post process. (default: 0)
  56976. * @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)
  56977. */
  56978. 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);
  56979. /**
  56980. * Updates the effect with the current post process compile time values and recompiles the shader.
  56981. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  56982. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  56983. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  56984. * @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
  56985. * @param onCompiled Called when the shader has been compiled.
  56986. * @param onError Called if there is an error when compiling a shader.
  56987. */
  56988. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  56989. }
  56990. }
  56991. declare module BABYLON {
  56992. /**
  56993. * Specifies the level of max blur that should be applied when using the depth of field effect
  56994. */
  56995. export enum DepthOfFieldEffectBlurLevel {
  56996. /**
  56997. * Subtle blur
  56998. */
  56999. Low = 0,
  57000. /**
  57001. * Medium blur
  57002. */
  57003. Medium = 1,
  57004. /**
  57005. * Large blur
  57006. */
  57007. High = 2
  57008. }
  57009. /**
  57010. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57011. */
  57012. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57013. private _circleOfConfusion;
  57014. /**
  57015. * @hidden Internal, blurs from high to low
  57016. */
  57017. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57018. private _depthOfFieldBlurY;
  57019. private _dofMerge;
  57020. /**
  57021. * @hidden Internal post processes in depth of field effect
  57022. */
  57023. _effects: Array<PostProcess>;
  57024. /**
  57025. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57026. */
  57027. focalLength: number;
  57028. /**
  57029. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57030. */
  57031. fStop: number;
  57032. /**
  57033. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57034. */
  57035. focusDistance: number;
  57036. /**
  57037. * 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.
  57038. */
  57039. lensSize: number;
  57040. /**
  57041. * Creates a new instance DepthOfFieldEffect
  57042. * @param scene The scene the effect belongs to.
  57043. * @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.
  57044. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57045. * @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)
  57046. */
  57047. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57048. /**
  57049. * Get the current class name of the current effet
  57050. * @returns "DepthOfFieldEffect"
  57051. */
  57052. getClassName(): string;
  57053. /**
  57054. * 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.
  57055. */
  57056. depthTexture: RenderTargetTexture;
  57057. /**
  57058. * Disposes each of the internal effects for a given camera.
  57059. * @param camera The camera to dispose the effect on.
  57060. */
  57061. disposeEffects(camera: Camera): void;
  57062. /**
  57063. * @hidden Internal
  57064. */
  57065. _updateEffects(): void;
  57066. /**
  57067. * Internal
  57068. * @returns if all the contained post processes are ready.
  57069. * @hidden
  57070. */
  57071. _isReady(): boolean;
  57072. }
  57073. }
  57074. declare module BABYLON {
  57075. /** @hidden */
  57076. export var displayPassPixelShader: {
  57077. name: string;
  57078. shader: string;
  57079. };
  57080. }
  57081. declare module BABYLON {
  57082. /**
  57083. * DisplayPassPostProcess which produces an output the same as it's input
  57084. */
  57085. export class DisplayPassPostProcess extends PostProcess {
  57086. /**
  57087. * Creates the DisplayPassPostProcess
  57088. * @param name The name of the effect.
  57089. * @param options The required width/height ratio to downsize to before computing the render pass.
  57090. * @param camera The camera to apply the render pass to.
  57091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57092. * @param engine The engine which the post process will be applied. (default: current engine)
  57093. * @param reusable If the post process can be reused on the same frame. (default: false)
  57094. */
  57095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57096. }
  57097. }
  57098. declare module BABYLON {
  57099. /** @hidden */
  57100. export var filterPixelShader: {
  57101. name: string;
  57102. shader: string;
  57103. };
  57104. }
  57105. declare module BABYLON {
  57106. /**
  57107. * Applies a kernel filter to the image
  57108. */
  57109. export class FilterPostProcess extends PostProcess {
  57110. /** The matrix to be applied to the image */
  57111. kernelMatrix: Matrix;
  57112. /**
  57113. *
  57114. * @param name The name of the effect.
  57115. * @param kernelMatrix The matrix to be applied to the image
  57116. * @param options The required width/height ratio to downsize to before computing the render pass.
  57117. * @param camera The camera to apply the render pass to.
  57118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57119. * @param engine The engine which the post process will be applied. (default: current engine)
  57120. * @param reusable If the post process can be reused on the same frame. (default: false)
  57121. */
  57122. constructor(name: string,
  57123. /** The matrix to be applied to the image */
  57124. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57125. }
  57126. }
  57127. declare module BABYLON {
  57128. /** @hidden */
  57129. export var fxaaPixelShader: {
  57130. name: string;
  57131. shader: string;
  57132. };
  57133. }
  57134. declare module BABYLON {
  57135. /** @hidden */
  57136. export var fxaaVertexShader: {
  57137. name: string;
  57138. shader: string;
  57139. };
  57140. }
  57141. declare module BABYLON {
  57142. /**
  57143. * Fxaa post process
  57144. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57145. */
  57146. export class FxaaPostProcess extends PostProcess {
  57147. /** @hidden */
  57148. texelWidth: number;
  57149. /** @hidden */
  57150. texelHeight: number;
  57151. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57152. private _getDefines;
  57153. }
  57154. }
  57155. declare module BABYLON {
  57156. /** @hidden */
  57157. export var grainPixelShader: {
  57158. name: string;
  57159. shader: string;
  57160. };
  57161. }
  57162. declare module BABYLON {
  57163. /**
  57164. * The GrainPostProcess adds noise to the image at mid luminance levels
  57165. */
  57166. export class GrainPostProcess extends PostProcess {
  57167. /**
  57168. * The intensity of the grain added (default: 30)
  57169. */
  57170. intensity: number;
  57171. /**
  57172. * If the grain should be randomized on every frame
  57173. */
  57174. animated: boolean;
  57175. /**
  57176. * Creates a new instance of @see GrainPostProcess
  57177. * @param name The name of the effect.
  57178. * @param options The required width/height ratio to downsize to before computing the render pass.
  57179. * @param camera The camera to apply the render pass to.
  57180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57181. * @param engine The engine which the post process will be applied. (default: current engine)
  57182. * @param reusable If the post process can be reused on the same frame. (default: false)
  57183. * @param textureType Type of textures used when performing the post process. (default: 0)
  57184. * @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)
  57185. */
  57186. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57187. }
  57188. }
  57189. declare module BABYLON {
  57190. /** @hidden */
  57191. export var highlightsPixelShader: {
  57192. name: string;
  57193. shader: string;
  57194. };
  57195. }
  57196. declare module BABYLON {
  57197. /**
  57198. * Extracts highlights from the image
  57199. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57200. */
  57201. export class HighlightsPostProcess extends PostProcess {
  57202. /**
  57203. * Extracts highlights from the image
  57204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57205. * @param name The name of the effect.
  57206. * @param options The required width/height ratio to downsize to before computing the render pass.
  57207. * @param camera The camera to apply the render pass to.
  57208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57209. * @param engine The engine which the post process will be applied. (default: current engine)
  57210. * @param reusable If the post process can be reused on the same frame. (default: false)
  57211. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57212. */
  57213. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57214. }
  57215. }
  57216. declare module BABYLON {
  57217. /** @hidden */
  57218. export var mrtFragmentDeclaration: {
  57219. name: string;
  57220. shader: string;
  57221. };
  57222. }
  57223. declare module BABYLON {
  57224. /** @hidden */
  57225. export var geometryPixelShader: {
  57226. name: string;
  57227. shader: string;
  57228. };
  57229. }
  57230. declare module BABYLON {
  57231. /** @hidden */
  57232. export var geometryVertexShader: {
  57233. name: string;
  57234. shader: string;
  57235. };
  57236. }
  57237. declare module BABYLON {
  57238. /** @hidden */
  57239. interface ISavedTransformationMatrix {
  57240. world: Matrix;
  57241. viewProjection: Matrix;
  57242. }
  57243. /**
  57244. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57245. */
  57246. export class GeometryBufferRenderer {
  57247. /**
  57248. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57249. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57250. */
  57251. static readonly POSITION_TEXTURE_TYPE: number;
  57252. /**
  57253. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57254. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57255. */
  57256. static readonly VELOCITY_TEXTURE_TYPE: number;
  57257. /**
  57258. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57259. * in order to compute objects velocities when enableVelocity is set to "true"
  57260. * @hidden
  57261. */
  57262. _previousTransformationMatrices: {
  57263. [index: number]: ISavedTransformationMatrix;
  57264. };
  57265. /**
  57266. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57267. * in order to compute objects velocities when enableVelocity is set to "true"
  57268. * @hidden
  57269. */
  57270. _previousBonesTransformationMatrices: {
  57271. [index: number]: Float32Array;
  57272. };
  57273. /**
  57274. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57275. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57276. */
  57277. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57278. private _scene;
  57279. private _multiRenderTarget;
  57280. private _ratio;
  57281. private _enablePosition;
  57282. private _enableVelocity;
  57283. private _positionIndex;
  57284. private _velocityIndex;
  57285. protected _effect: Effect;
  57286. protected _cachedDefines: string;
  57287. /**
  57288. * Set the render list (meshes to be rendered) used in the G buffer.
  57289. */
  57290. renderList: Mesh[];
  57291. /**
  57292. * Gets wether or not G buffer are supported by the running hardware.
  57293. * This requires draw buffer supports
  57294. */
  57295. readonly isSupported: boolean;
  57296. /**
  57297. * Returns the index of the given texture type in the G-Buffer textures array
  57298. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57299. * @returns the index of the given texture type in the G-Buffer textures array
  57300. */
  57301. getTextureIndex(textureType: number): number;
  57302. /**
  57303. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57304. */
  57305. /**
  57306. * Sets whether or not objects positions are enabled for the G buffer.
  57307. */
  57308. enablePosition: boolean;
  57309. /**
  57310. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57311. */
  57312. /**
  57313. * Sets wether or not objects velocities are enabled for the G buffer.
  57314. */
  57315. enableVelocity: boolean;
  57316. /**
  57317. * Gets the scene associated with the buffer.
  57318. */
  57319. readonly scene: Scene;
  57320. /**
  57321. * Gets the ratio used by the buffer during its creation.
  57322. * How big is the buffer related to the main canvas.
  57323. */
  57324. readonly ratio: number;
  57325. /** @hidden */
  57326. static _SceneComponentInitialization: (scene: Scene) => void;
  57327. /**
  57328. * Creates a new G Buffer for the scene
  57329. * @param scene The scene the buffer belongs to
  57330. * @param ratio How big is the buffer related to the main canvas.
  57331. */
  57332. constructor(scene: Scene, ratio?: number);
  57333. /**
  57334. * Checks wether everything is ready to render a submesh to the G buffer.
  57335. * @param subMesh the submesh to check readiness for
  57336. * @param useInstances is the mesh drawn using instance or not
  57337. * @returns true if ready otherwise false
  57338. */
  57339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57340. /**
  57341. * Gets the current underlying G Buffer.
  57342. * @returns the buffer
  57343. */
  57344. getGBuffer(): MultiRenderTarget;
  57345. /**
  57346. * Gets the number of samples used to render the buffer (anti aliasing).
  57347. */
  57348. /**
  57349. * Sets the number of samples used to render the buffer (anti aliasing).
  57350. */
  57351. samples: number;
  57352. /**
  57353. * Disposes the renderer and frees up associated resources.
  57354. */
  57355. dispose(): void;
  57356. protected _createRenderTargets(): void;
  57357. private _copyBonesTransformationMatrices;
  57358. }
  57359. }
  57360. declare module BABYLON {
  57361. interface Scene {
  57362. /** @hidden (Backing field) */
  57363. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57364. /**
  57365. * Gets or Sets the current geometry buffer associated to the scene.
  57366. */
  57367. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57368. /**
  57369. * Enables a GeometryBufferRender and associates it with the scene
  57370. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57371. * @returns the GeometryBufferRenderer
  57372. */
  57373. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57374. /**
  57375. * Disables the GeometryBufferRender associated with the scene
  57376. */
  57377. disableGeometryBufferRenderer(): void;
  57378. }
  57379. /**
  57380. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57381. * in several rendering techniques.
  57382. */
  57383. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57384. /**
  57385. * The component name helpful to identify the component in the list of scene components.
  57386. */
  57387. readonly name: string;
  57388. /**
  57389. * The scene the component belongs to.
  57390. */
  57391. scene: Scene;
  57392. /**
  57393. * Creates a new instance of the component for the given scene
  57394. * @param scene Defines the scene to register the component in
  57395. */
  57396. constructor(scene: Scene);
  57397. /**
  57398. * Registers the component in a given scene
  57399. */
  57400. register(): void;
  57401. /**
  57402. * Rebuilds the elements related to this component in case of
  57403. * context lost for instance.
  57404. */
  57405. rebuild(): void;
  57406. /**
  57407. * Disposes the component and the associated ressources
  57408. */
  57409. dispose(): void;
  57410. private _gatherRenderTargets;
  57411. }
  57412. }
  57413. declare module BABYLON {
  57414. /** @hidden */
  57415. export var motionBlurPixelShader: {
  57416. name: string;
  57417. shader: string;
  57418. };
  57419. }
  57420. declare module BABYLON {
  57421. /**
  57422. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57423. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57424. * As an example, all you have to do is to create the post-process:
  57425. * var mb = new BABYLON.MotionBlurPostProcess(
  57426. * 'mb', // The name of the effect.
  57427. * scene, // The scene containing the objects to blur according to their velocity.
  57428. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57429. * camera // The camera to apply the render pass to.
  57430. * );
  57431. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57432. */
  57433. export class MotionBlurPostProcess extends PostProcess {
  57434. /**
  57435. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57436. */
  57437. motionStrength: number;
  57438. /**
  57439. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57440. */
  57441. /**
  57442. * Sets the number of iterations to be used for motion blur quality
  57443. */
  57444. motionBlurSamples: number;
  57445. private _motionBlurSamples;
  57446. private _geometryBufferRenderer;
  57447. /**
  57448. * Creates a new instance MotionBlurPostProcess
  57449. * @param name The name of the effect.
  57450. * @param scene The scene containing the objects to blur according to their velocity.
  57451. * @param options The required width/height ratio to downsize to before computing the render pass.
  57452. * @param camera The camera to apply the render pass to.
  57453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57454. * @param engine The engine which the post process will be applied. (default: current engine)
  57455. * @param reusable If the post process can be reused on the same frame. (default: false)
  57456. * @param textureType Type of textures used when performing the post process. (default: 0)
  57457. * @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)
  57458. */
  57459. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57460. /**
  57461. * Excludes the given skinned mesh from computing bones velocities.
  57462. * 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.
  57463. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57464. */
  57465. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57466. /**
  57467. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57468. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57469. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57470. */
  57471. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57472. /**
  57473. * Disposes the post process.
  57474. * @param camera The camera to dispose the post process on.
  57475. */
  57476. dispose(camera?: Camera): void;
  57477. }
  57478. }
  57479. declare module BABYLON {
  57480. /** @hidden */
  57481. export var refractionPixelShader: {
  57482. name: string;
  57483. shader: string;
  57484. };
  57485. }
  57486. declare module BABYLON {
  57487. /**
  57488. * Post process which applies a refractin texture
  57489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57490. */
  57491. export class RefractionPostProcess extends PostProcess {
  57492. /** the base color of the refraction (used to taint the rendering) */
  57493. color: Color3;
  57494. /** simulated refraction depth */
  57495. depth: number;
  57496. /** the coefficient of the base color (0 to remove base color tainting) */
  57497. colorLevel: number;
  57498. private _refTexture;
  57499. private _ownRefractionTexture;
  57500. /**
  57501. * Gets or sets the refraction texture
  57502. * Please note that you are responsible for disposing the texture if you set it manually
  57503. */
  57504. refractionTexture: Texture;
  57505. /**
  57506. * Initializes the RefractionPostProcess
  57507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57508. * @param name The name of the effect.
  57509. * @param refractionTextureUrl Url of the refraction texture to use
  57510. * @param color the base color of the refraction (used to taint the rendering)
  57511. * @param depth simulated refraction depth
  57512. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57513. * @param camera The camera to apply the render pass to.
  57514. * @param options The required width/height ratio to downsize to before computing the render pass.
  57515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57516. * @param engine The engine which the post process will be applied. (default: current engine)
  57517. * @param reusable If the post process can be reused on the same frame. (default: false)
  57518. */
  57519. constructor(name: string, refractionTextureUrl: string,
  57520. /** the base color of the refraction (used to taint the rendering) */
  57521. color: Color3,
  57522. /** simulated refraction depth */
  57523. depth: number,
  57524. /** the coefficient of the base color (0 to remove base color tainting) */
  57525. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57526. /**
  57527. * Disposes of the post process
  57528. * @param camera Camera to dispose post process on
  57529. */
  57530. dispose(camera: Camera): void;
  57531. }
  57532. }
  57533. declare module BABYLON {
  57534. /** @hidden */
  57535. export var sharpenPixelShader: {
  57536. name: string;
  57537. shader: string;
  57538. };
  57539. }
  57540. declare module BABYLON {
  57541. /**
  57542. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57543. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57544. */
  57545. export class SharpenPostProcess extends PostProcess {
  57546. /**
  57547. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57548. */
  57549. colorAmount: number;
  57550. /**
  57551. * How much sharpness should be applied (default: 0.3)
  57552. */
  57553. edgeAmount: number;
  57554. /**
  57555. * Creates a new instance ConvolutionPostProcess
  57556. * @param name The name of the effect.
  57557. * @param options The required width/height ratio to downsize to before computing the render pass.
  57558. * @param camera The camera to apply the render pass to.
  57559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57560. * @param engine The engine which the post process will be applied. (default: current engine)
  57561. * @param reusable If the post process can be reused on the same frame. (default: false)
  57562. * @param textureType Type of textures used when performing the post process. (default: 0)
  57563. * @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)
  57564. */
  57565. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57566. }
  57567. }
  57568. declare module BABYLON {
  57569. /**
  57570. * PostProcessRenderPipeline
  57571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57572. */
  57573. export class PostProcessRenderPipeline {
  57574. private engine;
  57575. private _renderEffects;
  57576. private _renderEffectsForIsolatedPass;
  57577. /**
  57578. * List of inspectable custom properties (used by the Inspector)
  57579. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57580. */
  57581. inspectableCustomProperties: IInspectable[];
  57582. /**
  57583. * @hidden
  57584. */
  57585. protected _cameras: Camera[];
  57586. /** @hidden */
  57587. _name: string;
  57588. /**
  57589. * Gets pipeline name
  57590. */
  57591. readonly name: string;
  57592. /**
  57593. * Initializes a PostProcessRenderPipeline
  57594. * @param engine engine to add the pipeline to
  57595. * @param name name of the pipeline
  57596. */
  57597. constructor(engine: Engine, name: string);
  57598. /**
  57599. * Gets the class name
  57600. * @returns "PostProcessRenderPipeline"
  57601. */
  57602. getClassName(): string;
  57603. /**
  57604. * If all the render effects in the pipeline are supported
  57605. */
  57606. readonly isSupported: boolean;
  57607. /**
  57608. * Adds an effect to the pipeline
  57609. * @param renderEffect the effect to add
  57610. */
  57611. addEffect(renderEffect: PostProcessRenderEffect): void;
  57612. /** @hidden */
  57613. _rebuild(): void;
  57614. /** @hidden */
  57615. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57616. /** @hidden */
  57617. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57618. /** @hidden */
  57619. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57620. /** @hidden */
  57621. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57622. /** @hidden */
  57623. _attachCameras(cameras: Camera, unique: boolean): void;
  57624. /** @hidden */
  57625. _attachCameras(cameras: Camera[], unique: boolean): void;
  57626. /** @hidden */
  57627. _detachCameras(cameras: Camera): void;
  57628. /** @hidden */
  57629. _detachCameras(cameras: Nullable<Camera[]>): void;
  57630. /** @hidden */
  57631. _update(): void;
  57632. /** @hidden */
  57633. _reset(): void;
  57634. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57635. /**
  57636. * Disposes of the pipeline
  57637. */
  57638. dispose(): void;
  57639. }
  57640. }
  57641. declare module BABYLON {
  57642. /**
  57643. * PostProcessRenderPipelineManager class
  57644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57645. */
  57646. export class PostProcessRenderPipelineManager {
  57647. private _renderPipelines;
  57648. /**
  57649. * Initializes a PostProcessRenderPipelineManager
  57650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57651. */
  57652. constructor();
  57653. /**
  57654. * Gets the list of supported render pipelines
  57655. */
  57656. readonly supportedPipelines: PostProcessRenderPipeline[];
  57657. /**
  57658. * Adds a pipeline to the manager
  57659. * @param renderPipeline The pipeline to add
  57660. */
  57661. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57662. /**
  57663. * Attaches a camera to the pipeline
  57664. * @param renderPipelineName The name of the pipeline to attach to
  57665. * @param cameras the camera to attach
  57666. * @param unique if the camera can be attached multiple times to the pipeline
  57667. */
  57668. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57669. /**
  57670. * Detaches a camera from the pipeline
  57671. * @param renderPipelineName The name of the pipeline to detach from
  57672. * @param cameras the camera to detach
  57673. */
  57674. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57675. /**
  57676. * Enables an effect by name on a pipeline
  57677. * @param renderPipelineName the name of the pipeline to enable the effect in
  57678. * @param renderEffectName the name of the effect to enable
  57679. * @param cameras the cameras that the effect should be enabled on
  57680. */
  57681. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57682. /**
  57683. * Disables an effect by name on a pipeline
  57684. * @param renderPipelineName the name of the pipeline to disable the effect in
  57685. * @param renderEffectName the name of the effect to disable
  57686. * @param cameras the cameras that the effect should be disabled on
  57687. */
  57688. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57689. /**
  57690. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57691. */
  57692. update(): void;
  57693. /** @hidden */
  57694. _rebuild(): void;
  57695. /**
  57696. * Disposes of the manager and pipelines
  57697. */
  57698. dispose(): void;
  57699. }
  57700. }
  57701. declare module BABYLON {
  57702. interface Scene {
  57703. /** @hidden (Backing field) */
  57704. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57705. /**
  57706. * Gets the postprocess render pipeline manager
  57707. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57708. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57709. */
  57710. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57711. }
  57712. /**
  57713. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57714. */
  57715. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57716. /**
  57717. * The component name helpfull to identify the component in the list of scene components.
  57718. */
  57719. readonly name: string;
  57720. /**
  57721. * The scene the component belongs to.
  57722. */
  57723. scene: Scene;
  57724. /**
  57725. * Creates a new instance of the component for the given scene
  57726. * @param scene Defines the scene to register the component in
  57727. */
  57728. constructor(scene: Scene);
  57729. /**
  57730. * Registers the component in a given scene
  57731. */
  57732. register(): void;
  57733. /**
  57734. * Rebuilds the elements related to this component in case of
  57735. * context lost for instance.
  57736. */
  57737. rebuild(): void;
  57738. /**
  57739. * Disposes the component and the associated ressources
  57740. */
  57741. dispose(): void;
  57742. private _gatherRenderTargets;
  57743. }
  57744. }
  57745. declare module BABYLON {
  57746. /**
  57747. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57748. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57749. */
  57750. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57751. private _scene;
  57752. private _camerasToBeAttached;
  57753. /**
  57754. * ID of the sharpen post process,
  57755. */
  57756. private readonly SharpenPostProcessId;
  57757. /**
  57758. * @ignore
  57759. * ID of the image processing post process;
  57760. */
  57761. readonly ImageProcessingPostProcessId: string;
  57762. /**
  57763. * @ignore
  57764. * ID of the Fast Approximate Anti-Aliasing post process;
  57765. */
  57766. readonly FxaaPostProcessId: string;
  57767. /**
  57768. * ID of the chromatic aberration post process,
  57769. */
  57770. private readonly ChromaticAberrationPostProcessId;
  57771. /**
  57772. * ID of the grain post process
  57773. */
  57774. private readonly GrainPostProcessId;
  57775. /**
  57776. * Sharpen post process which will apply a sharpen convolution to enhance edges
  57777. */
  57778. sharpen: SharpenPostProcess;
  57779. private _sharpenEffect;
  57780. private bloom;
  57781. /**
  57782. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  57783. */
  57784. depthOfField: DepthOfFieldEffect;
  57785. /**
  57786. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57787. */
  57788. fxaa: FxaaPostProcess;
  57789. /**
  57790. * Image post processing pass used to perform operations such as tone mapping or color grading.
  57791. */
  57792. imageProcessing: ImageProcessingPostProcess;
  57793. /**
  57794. * Chromatic aberration post process which will shift rgb colors in the image
  57795. */
  57796. chromaticAberration: ChromaticAberrationPostProcess;
  57797. private _chromaticAberrationEffect;
  57798. /**
  57799. * Grain post process which add noise to the image
  57800. */
  57801. grain: GrainPostProcess;
  57802. private _grainEffect;
  57803. /**
  57804. * Glow post process which adds a glow to emissive areas of the image
  57805. */
  57806. private _glowLayer;
  57807. /**
  57808. * Animations which can be used to tweak settings over a period of time
  57809. */
  57810. animations: Animation[];
  57811. private _imageProcessingConfigurationObserver;
  57812. private _sharpenEnabled;
  57813. private _bloomEnabled;
  57814. private _depthOfFieldEnabled;
  57815. private _depthOfFieldBlurLevel;
  57816. private _fxaaEnabled;
  57817. private _imageProcessingEnabled;
  57818. private _defaultPipelineTextureType;
  57819. private _bloomScale;
  57820. private _chromaticAberrationEnabled;
  57821. private _grainEnabled;
  57822. private _buildAllowed;
  57823. /**
  57824. * Gets active scene
  57825. */
  57826. readonly scene: Scene;
  57827. /**
  57828. * Enable or disable the sharpen process from the pipeline
  57829. */
  57830. sharpenEnabled: boolean;
  57831. private _resizeObserver;
  57832. private _hardwareScaleLevel;
  57833. private _bloomKernel;
  57834. /**
  57835. * Specifies the size of the bloom blur kernel, relative to the final output size
  57836. */
  57837. bloomKernel: number;
  57838. /**
  57839. * Specifies the weight of the bloom in the final rendering
  57840. */
  57841. private _bloomWeight;
  57842. /**
  57843. * Specifies the luma threshold for the area that will be blurred by the bloom
  57844. */
  57845. private _bloomThreshold;
  57846. private _hdr;
  57847. /**
  57848. * The strength of the bloom.
  57849. */
  57850. bloomWeight: number;
  57851. /**
  57852. * The strength of the bloom.
  57853. */
  57854. bloomThreshold: number;
  57855. /**
  57856. * The scale of the bloom, lower value will provide better performance.
  57857. */
  57858. bloomScale: number;
  57859. /**
  57860. * Enable or disable the bloom from the pipeline
  57861. */
  57862. bloomEnabled: boolean;
  57863. private _rebuildBloom;
  57864. /**
  57865. * If the depth of field is enabled.
  57866. */
  57867. depthOfFieldEnabled: boolean;
  57868. /**
  57869. * Blur level of the depth of field effect. (Higher blur will effect performance)
  57870. */
  57871. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  57872. /**
  57873. * If the anti aliasing is enabled.
  57874. */
  57875. fxaaEnabled: boolean;
  57876. private _samples;
  57877. /**
  57878. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57879. */
  57880. samples: number;
  57881. /**
  57882. * If image processing is enabled.
  57883. */
  57884. imageProcessingEnabled: boolean;
  57885. /**
  57886. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  57887. */
  57888. glowLayerEnabled: boolean;
  57889. /**
  57890. * Gets the glow layer (or null if not defined)
  57891. */
  57892. readonly glowLayer: Nullable<GlowLayer>;
  57893. /**
  57894. * Enable or disable the chromaticAberration process from the pipeline
  57895. */
  57896. chromaticAberrationEnabled: boolean;
  57897. /**
  57898. * Enable or disable the grain process from the pipeline
  57899. */
  57900. grainEnabled: boolean;
  57901. /**
  57902. * @constructor
  57903. * @param name - The rendering pipeline name (default: "")
  57904. * @param hdr - If high dynamic range textures should be used (default: true)
  57905. * @param scene - The scene linked to this pipeline (default: the last created scene)
  57906. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  57907. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  57908. */
  57909. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  57910. /**
  57911. * Get the class name
  57912. * @returns "DefaultRenderingPipeline"
  57913. */
  57914. getClassName(): string;
  57915. /**
  57916. * Force the compilation of the entire pipeline.
  57917. */
  57918. prepare(): void;
  57919. private _hasCleared;
  57920. private _prevPostProcess;
  57921. private _prevPrevPostProcess;
  57922. private _setAutoClearAndTextureSharing;
  57923. private _depthOfFieldSceneObserver;
  57924. private _buildPipeline;
  57925. private _disposePostProcesses;
  57926. /**
  57927. * Adds a camera to the pipeline
  57928. * @param camera the camera to be added
  57929. */
  57930. addCamera(camera: Camera): void;
  57931. /**
  57932. * Removes a camera from the pipeline
  57933. * @param camera the camera to remove
  57934. */
  57935. removeCamera(camera: Camera): void;
  57936. /**
  57937. * Dispose of the pipeline and stop all post processes
  57938. */
  57939. dispose(): void;
  57940. /**
  57941. * Serialize the rendering pipeline (Used when exporting)
  57942. * @returns the serialized object
  57943. */
  57944. serialize(): any;
  57945. /**
  57946. * Parse the serialized pipeline
  57947. * @param source Source pipeline.
  57948. * @param scene The scene to load the pipeline to.
  57949. * @param rootUrl The URL of the serialized pipeline.
  57950. * @returns An instantiated pipeline from the serialized object.
  57951. */
  57952. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  57953. }
  57954. }
  57955. declare module BABYLON {
  57956. /** @hidden */
  57957. export var lensHighlightsPixelShader: {
  57958. name: string;
  57959. shader: string;
  57960. };
  57961. }
  57962. declare module BABYLON {
  57963. /** @hidden */
  57964. export var depthOfFieldPixelShader: {
  57965. name: string;
  57966. shader: string;
  57967. };
  57968. }
  57969. declare module BABYLON {
  57970. /**
  57971. * BABYLON.JS Chromatic Aberration GLSL Shader
  57972. * Author: Olivier Guyot
  57973. * Separates very slightly R, G and B colors on the edges of the screen
  57974. * Inspired by Francois Tarlier & Martins Upitis
  57975. */
  57976. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  57977. /**
  57978. * @ignore
  57979. * The chromatic aberration PostProcess id in the pipeline
  57980. */
  57981. LensChromaticAberrationEffect: string;
  57982. /**
  57983. * @ignore
  57984. * The highlights enhancing PostProcess id in the pipeline
  57985. */
  57986. HighlightsEnhancingEffect: string;
  57987. /**
  57988. * @ignore
  57989. * The depth-of-field PostProcess id in the pipeline
  57990. */
  57991. LensDepthOfFieldEffect: string;
  57992. private _scene;
  57993. private _depthTexture;
  57994. private _grainTexture;
  57995. private _chromaticAberrationPostProcess;
  57996. private _highlightsPostProcess;
  57997. private _depthOfFieldPostProcess;
  57998. private _edgeBlur;
  57999. private _grainAmount;
  58000. private _chromaticAberration;
  58001. private _distortion;
  58002. private _highlightsGain;
  58003. private _highlightsThreshold;
  58004. private _dofDistance;
  58005. private _dofAperture;
  58006. private _dofDarken;
  58007. private _dofPentagon;
  58008. private _blurNoise;
  58009. /**
  58010. * @constructor
  58011. *
  58012. * Effect parameters are as follow:
  58013. * {
  58014. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58015. * edge_blur: number; // from 0 to x (1 for realism)
  58016. * distortion: number; // from 0 to x (1 for realism)
  58017. * grain_amount: number; // from 0 to 1
  58018. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58019. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58020. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58021. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58022. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58023. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58024. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58025. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58026. * }
  58027. * Note: if an effect parameter is unset, effect is disabled
  58028. *
  58029. * @param name The rendering pipeline name
  58030. * @param parameters - An object containing all parameters (see above)
  58031. * @param scene The scene linked to this pipeline
  58032. * @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)
  58033. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58034. */
  58035. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58036. /**
  58037. * Get the class name
  58038. * @returns "LensRenderingPipeline"
  58039. */
  58040. getClassName(): string;
  58041. /**
  58042. * Gets associated scene
  58043. */
  58044. readonly scene: Scene;
  58045. /**
  58046. * Gets or sets the edge blur
  58047. */
  58048. edgeBlur: number;
  58049. /**
  58050. * Gets or sets the grain amount
  58051. */
  58052. grainAmount: number;
  58053. /**
  58054. * Gets or sets the chromatic aberration amount
  58055. */
  58056. chromaticAberration: number;
  58057. /**
  58058. * Gets or sets the depth of field aperture
  58059. */
  58060. dofAperture: number;
  58061. /**
  58062. * Gets or sets the edge distortion
  58063. */
  58064. edgeDistortion: number;
  58065. /**
  58066. * Gets or sets the depth of field distortion
  58067. */
  58068. dofDistortion: number;
  58069. /**
  58070. * Gets or sets the darken out of focus amount
  58071. */
  58072. darkenOutOfFocus: number;
  58073. /**
  58074. * Gets or sets a boolean indicating if blur noise is enabled
  58075. */
  58076. blurNoise: boolean;
  58077. /**
  58078. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58079. */
  58080. pentagonBokeh: boolean;
  58081. /**
  58082. * Gets or sets the highlight grain amount
  58083. */
  58084. highlightsGain: number;
  58085. /**
  58086. * Gets or sets the highlight threshold
  58087. */
  58088. highlightsThreshold: number;
  58089. /**
  58090. * Sets the amount of blur at the edges
  58091. * @param amount blur amount
  58092. */
  58093. setEdgeBlur(amount: number): void;
  58094. /**
  58095. * Sets edge blur to 0
  58096. */
  58097. disableEdgeBlur(): void;
  58098. /**
  58099. * Sets the amout of grain
  58100. * @param amount Amount of grain
  58101. */
  58102. setGrainAmount(amount: number): void;
  58103. /**
  58104. * Set grain amount to 0
  58105. */
  58106. disableGrain(): void;
  58107. /**
  58108. * Sets the chromatic aberration amount
  58109. * @param amount amount of chromatic aberration
  58110. */
  58111. setChromaticAberration(amount: number): void;
  58112. /**
  58113. * Sets chromatic aberration amount to 0
  58114. */
  58115. disableChromaticAberration(): void;
  58116. /**
  58117. * Sets the EdgeDistortion amount
  58118. * @param amount amount of EdgeDistortion
  58119. */
  58120. setEdgeDistortion(amount: number): void;
  58121. /**
  58122. * Sets edge distortion to 0
  58123. */
  58124. disableEdgeDistortion(): void;
  58125. /**
  58126. * Sets the FocusDistance amount
  58127. * @param amount amount of FocusDistance
  58128. */
  58129. setFocusDistance(amount: number): void;
  58130. /**
  58131. * Disables depth of field
  58132. */
  58133. disableDepthOfField(): void;
  58134. /**
  58135. * Sets the Aperture amount
  58136. * @param amount amount of Aperture
  58137. */
  58138. setAperture(amount: number): void;
  58139. /**
  58140. * Sets the DarkenOutOfFocus amount
  58141. * @param amount amount of DarkenOutOfFocus
  58142. */
  58143. setDarkenOutOfFocus(amount: number): void;
  58144. private _pentagonBokehIsEnabled;
  58145. /**
  58146. * Creates a pentagon bokeh effect
  58147. */
  58148. enablePentagonBokeh(): void;
  58149. /**
  58150. * Disables the pentagon bokeh effect
  58151. */
  58152. disablePentagonBokeh(): void;
  58153. /**
  58154. * Enables noise blur
  58155. */
  58156. enableNoiseBlur(): void;
  58157. /**
  58158. * Disables noise blur
  58159. */
  58160. disableNoiseBlur(): void;
  58161. /**
  58162. * Sets the HighlightsGain amount
  58163. * @param amount amount of HighlightsGain
  58164. */
  58165. setHighlightsGain(amount: number): void;
  58166. /**
  58167. * Sets the HighlightsThreshold amount
  58168. * @param amount amount of HighlightsThreshold
  58169. */
  58170. setHighlightsThreshold(amount: number): void;
  58171. /**
  58172. * Disables highlights
  58173. */
  58174. disableHighlights(): void;
  58175. /**
  58176. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58177. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58178. */
  58179. dispose(disableDepthRender?: boolean): void;
  58180. private _createChromaticAberrationPostProcess;
  58181. private _createHighlightsPostProcess;
  58182. private _createDepthOfFieldPostProcess;
  58183. private _createGrainTexture;
  58184. }
  58185. }
  58186. declare module BABYLON {
  58187. /** @hidden */
  58188. export var ssao2PixelShader: {
  58189. name: string;
  58190. shader: string;
  58191. };
  58192. }
  58193. declare module BABYLON {
  58194. /** @hidden */
  58195. export var ssaoCombinePixelShader: {
  58196. name: string;
  58197. shader: string;
  58198. };
  58199. }
  58200. declare module BABYLON {
  58201. /**
  58202. * Render pipeline to produce ssao effect
  58203. */
  58204. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58205. /**
  58206. * @ignore
  58207. * The PassPostProcess id in the pipeline that contains the original scene color
  58208. */
  58209. SSAOOriginalSceneColorEffect: string;
  58210. /**
  58211. * @ignore
  58212. * The SSAO PostProcess id in the pipeline
  58213. */
  58214. SSAORenderEffect: string;
  58215. /**
  58216. * @ignore
  58217. * The horizontal blur PostProcess id in the pipeline
  58218. */
  58219. SSAOBlurHRenderEffect: string;
  58220. /**
  58221. * @ignore
  58222. * The vertical blur PostProcess id in the pipeline
  58223. */
  58224. SSAOBlurVRenderEffect: string;
  58225. /**
  58226. * @ignore
  58227. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58228. */
  58229. SSAOCombineRenderEffect: string;
  58230. /**
  58231. * The output strength of the SSAO post-process. Default value is 1.0.
  58232. */
  58233. totalStrength: number;
  58234. /**
  58235. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58236. */
  58237. maxZ: number;
  58238. /**
  58239. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58240. */
  58241. minZAspect: number;
  58242. private _samples;
  58243. /**
  58244. * Number of samples used for the SSAO calculations. Default value is 8
  58245. */
  58246. samples: number;
  58247. private _textureSamples;
  58248. /**
  58249. * Number of samples to use for antialiasing
  58250. */
  58251. textureSamples: number;
  58252. /**
  58253. * Ratio object used for SSAO ratio and blur ratio
  58254. */
  58255. private _ratio;
  58256. /**
  58257. * Dynamically generated sphere sampler.
  58258. */
  58259. private _sampleSphere;
  58260. /**
  58261. * Blur filter offsets
  58262. */
  58263. private _samplerOffsets;
  58264. private _expensiveBlur;
  58265. /**
  58266. * If bilateral blur should be used
  58267. */
  58268. expensiveBlur: boolean;
  58269. /**
  58270. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58271. */
  58272. radius: number;
  58273. /**
  58274. * The base color of the SSAO post-process
  58275. * The final result is "base + ssao" between [0, 1]
  58276. */
  58277. base: number;
  58278. /**
  58279. * Support test.
  58280. */
  58281. static readonly IsSupported: boolean;
  58282. private _scene;
  58283. private _depthTexture;
  58284. private _normalTexture;
  58285. private _randomTexture;
  58286. private _originalColorPostProcess;
  58287. private _ssaoPostProcess;
  58288. private _blurHPostProcess;
  58289. private _blurVPostProcess;
  58290. private _ssaoCombinePostProcess;
  58291. private _firstUpdate;
  58292. /**
  58293. * Gets active scene
  58294. */
  58295. readonly scene: Scene;
  58296. /**
  58297. * @constructor
  58298. * @param name The rendering pipeline name
  58299. * @param scene The scene linked to this pipeline
  58300. * @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 }
  58301. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58302. */
  58303. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58304. /**
  58305. * Get the class name
  58306. * @returns "SSAO2RenderingPipeline"
  58307. */
  58308. getClassName(): string;
  58309. /**
  58310. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58311. */
  58312. dispose(disableGeometryBufferRenderer?: boolean): void;
  58313. private _createBlurPostProcess;
  58314. /** @hidden */
  58315. _rebuild(): void;
  58316. private _bits;
  58317. private _radicalInverse_VdC;
  58318. private _hammersley;
  58319. private _hemisphereSample_uniform;
  58320. private _generateHemisphere;
  58321. private _createSSAOPostProcess;
  58322. private _createSSAOCombinePostProcess;
  58323. private _createRandomTexture;
  58324. /**
  58325. * Serialize the rendering pipeline (Used when exporting)
  58326. * @returns the serialized object
  58327. */
  58328. serialize(): any;
  58329. /**
  58330. * Parse the serialized pipeline
  58331. * @param source Source pipeline.
  58332. * @param scene The scene to load the pipeline to.
  58333. * @param rootUrl The URL of the serialized pipeline.
  58334. * @returns An instantiated pipeline from the serialized object.
  58335. */
  58336. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58337. }
  58338. }
  58339. declare module BABYLON {
  58340. /** @hidden */
  58341. export var ssaoPixelShader: {
  58342. name: string;
  58343. shader: string;
  58344. };
  58345. }
  58346. declare module BABYLON {
  58347. /**
  58348. * Render pipeline to produce ssao effect
  58349. */
  58350. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58351. /**
  58352. * @ignore
  58353. * The PassPostProcess id in the pipeline that contains the original scene color
  58354. */
  58355. SSAOOriginalSceneColorEffect: string;
  58356. /**
  58357. * @ignore
  58358. * The SSAO PostProcess id in the pipeline
  58359. */
  58360. SSAORenderEffect: string;
  58361. /**
  58362. * @ignore
  58363. * The horizontal blur PostProcess id in the pipeline
  58364. */
  58365. SSAOBlurHRenderEffect: string;
  58366. /**
  58367. * @ignore
  58368. * The vertical blur PostProcess id in the pipeline
  58369. */
  58370. SSAOBlurVRenderEffect: string;
  58371. /**
  58372. * @ignore
  58373. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58374. */
  58375. SSAOCombineRenderEffect: string;
  58376. /**
  58377. * The output strength of the SSAO post-process. Default value is 1.0.
  58378. */
  58379. totalStrength: number;
  58380. /**
  58381. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58382. */
  58383. radius: number;
  58384. /**
  58385. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58386. * Must not be equal to fallOff and superior to fallOff.
  58387. * Default value is 0.0075
  58388. */
  58389. area: number;
  58390. /**
  58391. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58392. * Must not be equal to area and inferior to area.
  58393. * Default value is 0.000001
  58394. */
  58395. fallOff: number;
  58396. /**
  58397. * The base color of the SSAO post-process
  58398. * The final result is "base + ssao" between [0, 1]
  58399. */
  58400. base: number;
  58401. private _scene;
  58402. private _depthTexture;
  58403. private _randomTexture;
  58404. private _originalColorPostProcess;
  58405. private _ssaoPostProcess;
  58406. private _blurHPostProcess;
  58407. private _blurVPostProcess;
  58408. private _ssaoCombinePostProcess;
  58409. private _firstUpdate;
  58410. /**
  58411. * Gets active scene
  58412. */
  58413. readonly scene: Scene;
  58414. /**
  58415. * @constructor
  58416. * @param name - The rendering pipeline name
  58417. * @param scene - The scene linked to this pipeline
  58418. * @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 }
  58419. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58420. */
  58421. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58422. /**
  58423. * Get the class name
  58424. * @returns "SSAORenderingPipeline"
  58425. */
  58426. getClassName(): string;
  58427. /**
  58428. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58429. */
  58430. dispose(disableDepthRender?: boolean): void;
  58431. private _createBlurPostProcess;
  58432. /** @hidden */
  58433. _rebuild(): void;
  58434. private _createSSAOPostProcess;
  58435. private _createSSAOCombinePostProcess;
  58436. private _createRandomTexture;
  58437. }
  58438. }
  58439. declare module BABYLON {
  58440. /** @hidden */
  58441. export var standardPixelShader: {
  58442. name: string;
  58443. shader: string;
  58444. };
  58445. }
  58446. declare module BABYLON {
  58447. /**
  58448. * Standard rendering pipeline
  58449. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58450. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58451. */
  58452. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58453. /**
  58454. * Public members
  58455. */
  58456. /**
  58457. * Post-process which contains the original scene color before the pipeline applies all the effects
  58458. */
  58459. originalPostProcess: Nullable<PostProcess>;
  58460. /**
  58461. * Post-process used to down scale an image x4
  58462. */
  58463. downSampleX4PostProcess: Nullable<PostProcess>;
  58464. /**
  58465. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58466. */
  58467. brightPassPostProcess: Nullable<PostProcess>;
  58468. /**
  58469. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58470. */
  58471. blurHPostProcesses: PostProcess[];
  58472. /**
  58473. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58474. */
  58475. blurVPostProcesses: PostProcess[];
  58476. /**
  58477. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58478. */
  58479. textureAdderPostProcess: Nullable<PostProcess>;
  58480. /**
  58481. * Post-process used to create volumetric lighting effect
  58482. */
  58483. volumetricLightPostProcess: Nullable<PostProcess>;
  58484. /**
  58485. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58486. */
  58487. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58488. /**
  58489. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58490. */
  58491. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58492. /**
  58493. * Post-process used to merge the volumetric light effect and the real scene color
  58494. */
  58495. volumetricLightMergePostProces: Nullable<PostProcess>;
  58496. /**
  58497. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58498. */
  58499. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58500. /**
  58501. * Base post-process used to calculate the average luminance of the final image for HDR
  58502. */
  58503. luminancePostProcess: Nullable<PostProcess>;
  58504. /**
  58505. * Post-processes used to create down sample post-processes in order to get
  58506. * the average luminance of the final image for HDR
  58507. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58508. */
  58509. luminanceDownSamplePostProcesses: PostProcess[];
  58510. /**
  58511. * Post-process used to create a HDR effect (light adaptation)
  58512. */
  58513. hdrPostProcess: Nullable<PostProcess>;
  58514. /**
  58515. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58516. */
  58517. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58518. /**
  58519. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58520. */
  58521. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58522. /**
  58523. * Post-process used to merge the final HDR post-process and the real scene color
  58524. */
  58525. hdrFinalPostProcess: Nullable<PostProcess>;
  58526. /**
  58527. * Post-process used to create a lens flare effect
  58528. */
  58529. lensFlarePostProcess: Nullable<PostProcess>;
  58530. /**
  58531. * Post-process that merges the result of the lens flare post-process and the real scene color
  58532. */
  58533. lensFlareComposePostProcess: Nullable<PostProcess>;
  58534. /**
  58535. * Post-process used to create a motion blur effect
  58536. */
  58537. motionBlurPostProcess: Nullable<PostProcess>;
  58538. /**
  58539. * Post-process used to create a depth of field effect
  58540. */
  58541. depthOfFieldPostProcess: Nullable<PostProcess>;
  58542. /**
  58543. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58544. */
  58545. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58546. /**
  58547. * Represents the brightness threshold in order to configure the illuminated surfaces
  58548. */
  58549. brightThreshold: number;
  58550. /**
  58551. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58552. */
  58553. blurWidth: number;
  58554. /**
  58555. * Sets if the blur for highlighted surfaces must be only horizontal
  58556. */
  58557. horizontalBlur: boolean;
  58558. /**
  58559. * Gets the overall exposure used by the pipeline
  58560. */
  58561. /**
  58562. * Sets the overall exposure used by the pipeline
  58563. */
  58564. exposure: number;
  58565. /**
  58566. * Texture used typically to simulate "dirty" on camera lens
  58567. */
  58568. lensTexture: Nullable<Texture>;
  58569. /**
  58570. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58571. */
  58572. volumetricLightCoefficient: number;
  58573. /**
  58574. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58575. */
  58576. volumetricLightPower: number;
  58577. /**
  58578. * Used the set the blur intensity to smooth the volumetric lights
  58579. */
  58580. volumetricLightBlurScale: number;
  58581. /**
  58582. * Light (spot or directional) used to generate the volumetric lights rays
  58583. * The source light must have a shadow generate so the pipeline can get its
  58584. * depth map
  58585. */
  58586. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58587. /**
  58588. * For eye adaptation, represents the minimum luminance the eye can see
  58589. */
  58590. hdrMinimumLuminance: number;
  58591. /**
  58592. * For eye adaptation, represents the decrease luminance speed
  58593. */
  58594. hdrDecreaseRate: number;
  58595. /**
  58596. * For eye adaptation, represents the increase luminance speed
  58597. */
  58598. hdrIncreaseRate: number;
  58599. /**
  58600. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58601. */
  58602. /**
  58603. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58604. */
  58605. hdrAutoExposure: boolean;
  58606. /**
  58607. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58608. */
  58609. lensColorTexture: Nullable<Texture>;
  58610. /**
  58611. * The overall strengh for the lens flare effect
  58612. */
  58613. lensFlareStrength: number;
  58614. /**
  58615. * Dispersion coefficient for lens flare ghosts
  58616. */
  58617. lensFlareGhostDispersal: number;
  58618. /**
  58619. * Main lens flare halo width
  58620. */
  58621. lensFlareHaloWidth: number;
  58622. /**
  58623. * Based on the lens distortion effect, defines how much the lens flare result
  58624. * is distorted
  58625. */
  58626. lensFlareDistortionStrength: number;
  58627. /**
  58628. * Lens star texture must be used to simulate rays on the flares and is available
  58629. * in the documentation
  58630. */
  58631. lensStarTexture: Nullable<Texture>;
  58632. /**
  58633. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58634. * flare effect by taking account of the dirt texture
  58635. */
  58636. lensFlareDirtTexture: Nullable<Texture>;
  58637. /**
  58638. * Represents the focal length for the depth of field effect
  58639. */
  58640. depthOfFieldDistance: number;
  58641. /**
  58642. * Represents the blur intensity for the blurred part of the depth of field effect
  58643. */
  58644. depthOfFieldBlurWidth: number;
  58645. /**
  58646. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58647. */
  58648. /**
  58649. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58650. */
  58651. motionStrength: number;
  58652. /**
  58653. * Gets wether or not the motion blur post-process is object based or screen based.
  58654. */
  58655. /**
  58656. * Sets wether or not the motion blur post-process should be object based or screen based
  58657. */
  58658. objectBasedMotionBlur: boolean;
  58659. /**
  58660. * List of animations for the pipeline (IAnimatable implementation)
  58661. */
  58662. animations: Animation[];
  58663. /**
  58664. * Private members
  58665. */
  58666. private _scene;
  58667. private _currentDepthOfFieldSource;
  58668. private _basePostProcess;
  58669. private _fixedExposure;
  58670. private _currentExposure;
  58671. private _hdrAutoExposure;
  58672. private _hdrCurrentLuminance;
  58673. private _motionStrength;
  58674. private _isObjectBasedMotionBlur;
  58675. private _floatTextureType;
  58676. private _ratio;
  58677. private _bloomEnabled;
  58678. private _depthOfFieldEnabled;
  58679. private _vlsEnabled;
  58680. private _lensFlareEnabled;
  58681. private _hdrEnabled;
  58682. private _motionBlurEnabled;
  58683. private _fxaaEnabled;
  58684. private _motionBlurSamples;
  58685. private _volumetricLightStepsCount;
  58686. private _samples;
  58687. /**
  58688. * @ignore
  58689. * Specifies if the bloom pipeline is enabled
  58690. */
  58691. BloomEnabled: boolean;
  58692. /**
  58693. * @ignore
  58694. * Specifies if the depth of field pipeline is enabed
  58695. */
  58696. DepthOfFieldEnabled: boolean;
  58697. /**
  58698. * @ignore
  58699. * Specifies if the lens flare pipeline is enabed
  58700. */
  58701. LensFlareEnabled: boolean;
  58702. /**
  58703. * @ignore
  58704. * Specifies if the HDR pipeline is enabled
  58705. */
  58706. HDREnabled: boolean;
  58707. /**
  58708. * @ignore
  58709. * Specifies if the volumetric lights scattering effect is enabled
  58710. */
  58711. VLSEnabled: boolean;
  58712. /**
  58713. * @ignore
  58714. * Specifies if the motion blur effect is enabled
  58715. */
  58716. MotionBlurEnabled: boolean;
  58717. /**
  58718. * Specifies if anti-aliasing is enabled
  58719. */
  58720. fxaaEnabled: boolean;
  58721. /**
  58722. * Specifies the number of steps used to calculate the volumetric lights
  58723. * Typically in interval [50, 200]
  58724. */
  58725. volumetricLightStepsCount: number;
  58726. /**
  58727. * Specifies the number of samples used for the motion blur effect
  58728. * Typically in interval [16, 64]
  58729. */
  58730. motionBlurSamples: number;
  58731. /**
  58732. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58733. */
  58734. samples: number;
  58735. /**
  58736. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58737. * @constructor
  58738. * @param name The rendering pipeline name
  58739. * @param scene The scene linked to this pipeline
  58740. * @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)
  58741. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58742. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58743. */
  58744. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58745. private _buildPipeline;
  58746. private _createDownSampleX4PostProcess;
  58747. private _createBrightPassPostProcess;
  58748. private _createBlurPostProcesses;
  58749. private _createTextureAdderPostProcess;
  58750. private _createVolumetricLightPostProcess;
  58751. private _createLuminancePostProcesses;
  58752. private _createHdrPostProcess;
  58753. private _createLensFlarePostProcess;
  58754. private _createDepthOfFieldPostProcess;
  58755. private _createMotionBlurPostProcess;
  58756. private _getDepthTexture;
  58757. private _disposePostProcesses;
  58758. /**
  58759. * Dispose of the pipeline and stop all post processes
  58760. */
  58761. dispose(): void;
  58762. /**
  58763. * Serialize the rendering pipeline (Used when exporting)
  58764. * @returns the serialized object
  58765. */
  58766. serialize(): any;
  58767. /**
  58768. * Parse the serialized pipeline
  58769. * @param source Source pipeline.
  58770. * @param scene The scene to load the pipeline to.
  58771. * @param rootUrl The URL of the serialized pipeline.
  58772. * @returns An instantiated pipeline from the serialized object.
  58773. */
  58774. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  58775. /**
  58776. * Luminance steps
  58777. */
  58778. static LuminanceSteps: number;
  58779. }
  58780. }
  58781. declare module BABYLON {
  58782. /** @hidden */
  58783. export var tonemapPixelShader: {
  58784. name: string;
  58785. shader: string;
  58786. };
  58787. }
  58788. declare module BABYLON {
  58789. /** Defines operator used for tonemapping */
  58790. export enum TonemappingOperator {
  58791. /** Hable */
  58792. Hable = 0,
  58793. /** Reinhard */
  58794. Reinhard = 1,
  58795. /** HejiDawson */
  58796. HejiDawson = 2,
  58797. /** Photographic */
  58798. Photographic = 3
  58799. }
  58800. /**
  58801. * Defines a post process to apply tone mapping
  58802. */
  58803. export class TonemapPostProcess extends PostProcess {
  58804. private _operator;
  58805. /** Defines the required exposure adjustement */
  58806. exposureAdjustment: number;
  58807. /**
  58808. * Creates a new TonemapPostProcess
  58809. * @param name defines the name of the postprocess
  58810. * @param _operator defines the operator to use
  58811. * @param exposureAdjustment defines the required exposure adjustement
  58812. * @param camera defines the camera to use (can be null)
  58813. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  58814. * @param engine defines the hosting engine (can be ignore if camera is set)
  58815. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58816. */
  58817. constructor(name: string, _operator: TonemappingOperator,
  58818. /** Defines the required exposure adjustement */
  58819. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  58820. }
  58821. }
  58822. declare module BABYLON {
  58823. /** @hidden */
  58824. export var depthVertexShader: {
  58825. name: string;
  58826. shader: string;
  58827. };
  58828. }
  58829. declare module BABYLON {
  58830. /** @hidden */
  58831. export var volumetricLightScatteringPixelShader: {
  58832. name: string;
  58833. shader: string;
  58834. };
  58835. }
  58836. declare module BABYLON {
  58837. /** @hidden */
  58838. export var volumetricLightScatteringPassVertexShader: {
  58839. name: string;
  58840. shader: string;
  58841. };
  58842. }
  58843. declare module BABYLON {
  58844. /** @hidden */
  58845. export var volumetricLightScatteringPassPixelShader: {
  58846. name: string;
  58847. shader: string;
  58848. };
  58849. }
  58850. declare module BABYLON {
  58851. /**
  58852. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  58853. */
  58854. export class VolumetricLightScatteringPostProcess extends PostProcess {
  58855. private _volumetricLightScatteringPass;
  58856. private _volumetricLightScatteringRTT;
  58857. private _viewPort;
  58858. private _screenCoordinates;
  58859. private _cachedDefines;
  58860. /**
  58861. * If not undefined, the mesh position is computed from the attached node position
  58862. */
  58863. attachedNode: {
  58864. position: Vector3;
  58865. };
  58866. /**
  58867. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  58868. */
  58869. customMeshPosition: Vector3;
  58870. /**
  58871. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  58872. */
  58873. useCustomMeshPosition: boolean;
  58874. /**
  58875. * If the post-process should inverse the light scattering direction
  58876. */
  58877. invert: boolean;
  58878. /**
  58879. * The internal mesh used by the post-process
  58880. */
  58881. mesh: Mesh;
  58882. /**
  58883. * @hidden
  58884. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  58885. */
  58886. useDiffuseColor: boolean;
  58887. /**
  58888. * Array containing the excluded meshes not rendered in the internal pass
  58889. */
  58890. excludedMeshes: AbstractMesh[];
  58891. /**
  58892. * Controls the overall intensity of the post-process
  58893. */
  58894. exposure: number;
  58895. /**
  58896. * Dissipates each sample's contribution in range [0, 1]
  58897. */
  58898. decay: number;
  58899. /**
  58900. * Controls the overall intensity of each sample
  58901. */
  58902. weight: number;
  58903. /**
  58904. * Controls the density of each sample
  58905. */
  58906. density: number;
  58907. /**
  58908. * @constructor
  58909. * @param name The post-process name
  58910. * @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)
  58911. * @param camera The camera that the post-process will be attached to
  58912. * @param mesh The mesh used to create the light scattering
  58913. * @param samples The post-process quality, default 100
  58914. * @param samplingModeThe post-process filtering mode
  58915. * @param engine The babylon engine
  58916. * @param reusable If the post-process is reusable
  58917. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  58918. */
  58919. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  58920. /**
  58921. * Returns the string "VolumetricLightScatteringPostProcess"
  58922. * @returns "VolumetricLightScatteringPostProcess"
  58923. */
  58924. getClassName(): string;
  58925. private _isReady;
  58926. /**
  58927. * Sets the new light position for light scattering effect
  58928. * @param position The new custom light position
  58929. */
  58930. setCustomMeshPosition(position: Vector3): void;
  58931. /**
  58932. * Returns the light position for light scattering effect
  58933. * @return Vector3 The custom light position
  58934. */
  58935. getCustomMeshPosition(): Vector3;
  58936. /**
  58937. * Disposes the internal assets and detaches the post-process from the camera
  58938. */
  58939. dispose(camera: Camera): void;
  58940. /**
  58941. * Returns the render target texture used by the post-process
  58942. * @return the render target texture used by the post-process
  58943. */
  58944. getPass(): RenderTargetTexture;
  58945. private _meshExcluded;
  58946. private _createPass;
  58947. private _updateMeshScreenCoordinates;
  58948. /**
  58949. * Creates a default mesh for the Volumeric Light Scattering post-process
  58950. * @param name The mesh name
  58951. * @param scene The scene where to create the mesh
  58952. * @return the default mesh
  58953. */
  58954. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  58955. }
  58956. }
  58957. declare module BABYLON {
  58958. interface Scene {
  58959. /** @hidden (Backing field) */
  58960. _boundingBoxRenderer: BoundingBoxRenderer;
  58961. /** @hidden (Backing field) */
  58962. _forceShowBoundingBoxes: boolean;
  58963. /**
  58964. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  58965. */
  58966. forceShowBoundingBoxes: boolean;
  58967. /**
  58968. * Gets the bounding box renderer associated with the scene
  58969. * @returns a BoundingBoxRenderer
  58970. */
  58971. getBoundingBoxRenderer(): BoundingBoxRenderer;
  58972. }
  58973. interface AbstractMesh {
  58974. /** @hidden (Backing field) */
  58975. _showBoundingBox: boolean;
  58976. /**
  58977. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  58978. */
  58979. showBoundingBox: boolean;
  58980. }
  58981. /**
  58982. * Component responsible of rendering the bounding box of the meshes in a scene.
  58983. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  58984. */
  58985. export class BoundingBoxRenderer implements ISceneComponent {
  58986. /**
  58987. * The component name helpfull to identify the component in the list of scene components.
  58988. */
  58989. readonly name: string;
  58990. /**
  58991. * The scene the component belongs to.
  58992. */
  58993. scene: Scene;
  58994. /**
  58995. * Color of the bounding box lines placed in front of an object
  58996. */
  58997. frontColor: Color3;
  58998. /**
  58999. * Color of the bounding box lines placed behind an object
  59000. */
  59001. backColor: Color3;
  59002. /**
  59003. * Defines if the renderer should show the back lines or not
  59004. */
  59005. showBackLines: boolean;
  59006. /**
  59007. * @hidden
  59008. */
  59009. renderList: SmartArray<BoundingBox>;
  59010. private _colorShader;
  59011. private _vertexBuffers;
  59012. private _indexBuffer;
  59013. private _fillIndexBuffer;
  59014. private _fillIndexData;
  59015. /**
  59016. * Instantiates a new bounding box renderer in a scene.
  59017. * @param scene the scene the renderer renders in
  59018. */
  59019. constructor(scene: Scene);
  59020. /**
  59021. * Registers the component in a given scene
  59022. */
  59023. register(): void;
  59024. private _evaluateSubMesh;
  59025. private _activeMesh;
  59026. private _prepareRessources;
  59027. private _createIndexBuffer;
  59028. /**
  59029. * Rebuilds the elements related to this component in case of
  59030. * context lost for instance.
  59031. */
  59032. rebuild(): void;
  59033. /**
  59034. * @hidden
  59035. */
  59036. reset(): void;
  59037. /**
  59038. * Render the bounding boxes of a specific rendering group
  59039. * @param renderingGroupId defines the rendering group to render
  59040. */
  59041. render(renderingGroupId: number): void;
  59042. /**
  59043. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59044. * @param mesh Define the mesh to render the occlusion bounding box for
  59045. */
  59046. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59047. /**
  59048. * Dispose and release the resources attached to this renderer.
  59049. */
  59050. dispose(): void;
  59051. }
  59052. }
  59053. declare module BABYLON {
  59054. /** @hidden */
  59055. export var depthPixelShader: {
  59056. name: string;
  59057. shader: string;
  59058. };
  59059. }
  59060. declare module BABYLON {
  59061. /**
  59062. * This represents a depth renderer in Babylon.
  59063. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59064. */
  59065. export class DepthRenderer {
  59066. private _scene;
  59067. private _depthMap;
  59068. private _effect;
  59069. private readonly _storeNonLinearDepth;
  59070. private readonly _clearColor;
  59071. /** Get if the depth renderer is using packed depth or not */
  59072. readonly isPacked: boolean;
  59073. private _cachedDefines;
  59074. private _camera;
  59075. /**
  59076. * Specifiess that the depth renderer will only be used within
  59077. * the camera it is created for.
  59078. * This can help forcing its rendering during the camera processing.
  59079. */
  59080. useOnlyInActiveCamera: boolean;
  59081. /** @hidden */
  59082. static _SceneComponentInitialization: (scene: Scene) => void;
  59083. /**
  59084. * Instantiates a depth renderer
  59085. * @param scene The scene the renderer belongs to
  59086. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59087. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59088. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59089. */
  59090. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59091. /**
  59092. * Creates the depth rendering effect and checks if the effect is ready.
  59093. * @param subMesh The submesh to be used to render the depth map of
  59094. * @param useInstances If multiple world instances should be used
  59095. * @returns if the depth renderer is ready to render the depth map
  59096. */
  59097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59098. /**
  59099. * Gets the texture which the depth map will be written to.
  59100. * @returns The depth map texture
  59101. */
  59102. getDepthMap(): RenderTargetTexture;
  59103. /**
  59104. * Disposes of the depth renderer.
  59105. */
  59106. dispose(): void;
  59107. }
  59108. }
  59109. declare module BABYLON {
  59110. interface Scene {
  59111. /** @hidden (Backing field) */
  59112. _depthRenderer: {
  59113. [id: string]: DepthRenderer;
  59114. };
  59115. /**
  59116. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59117. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59118. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59119. * @returns the created depth renderer
  59120. */
  59121. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59122. /**
  59123. * Disables a depth renderer for a given camera
  59124. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59125. */
  59126. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59127. }
  59128. /**
  59129. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59130. * in several rendering techniques.
  59131. */
  59132. export class DepthRendererSceneComponent implements ISceneComponent {
  59133. /**
  59134. * The component name helpfull to identify the component in the list of scene components.
  59135. */
  59136. readonly name: string;
  59137. /**
  59138. * The scene the component belongs to.
  59139. */
  59140. scene: Scene;
  59141. /**
  59142. * Creates a new instance of the component for the given scene
  59143. * @param scene Defines the scene to register the component in
  59144. */
  59145. constructor(scene: Scene);
  59146. /**
  59147. * Registers the component in a given scene
  59148. */
  59149. register(): void;
  59150. /**
  59151. * Rebuilds the elements related to this component in case of
  59152. * context lost for instance.
  59153. */
  59154. rebuild(): void;
  59155. /**
  59156. * Disposes the component and the associated ressources
  59157. */
  59158. dispose(): void;
  59159. private _gatherRenderTargets;
  59160. private _gatherActiveCameraRenderTargets;
  59161. }
  59162. }
  59163. declare module BABYLON {
  59164. /** @hidden */
  59165. export var outlinePixelShader: {
  59166. name: string;
  59167. shader: string;
  59168. };
  59169. }
  59170. declare module BABYLON {
  59171. /** @hidden */
  59172. export var outlineVertexShader: {
  59173. name: string;
  59174. shader: string;
  59175. };
  59176. }
  59177. declare module BABYLON {
  59178. interface Scene {
  59179. /** @hidden */
  59180. _outlineRenderer: OutlineRenderer;
  59181. /**
  59182. * Gets the outline renderer associated with the scene
  59183. * @returns a OutlineRenderer
  59184. */
  59185. getOutlineRenderer(): OutlineRenderer;
  59186. }
  59187. interface AbstractMesh {
  59188. /** @hidden (Backing field) */
  59189. _renderOutline: boolean;
  59190. /**
  59191. * Gets or sets a boolean indicating if the outline must be rendered as well
  59192. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59193. */
  59194. renderOutline: boolean;
  59195. /** @hidden (Backing field) */
  59196. _renderOverlay: boolean;
  59197. /**
  59198. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59199. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59200. */
  59201. renderOverlay: boolean;
  59202. }
  59203. /**
  59204. * This class is responsible to draw bothe outline/overlay of meshes.
  59205. * It should not be used directly but through the available method on mesh.
  59206. */
  59207. export class OutlineRenderer implements ISceneComponent {
  59208. /**
  59209. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59210. */
  59211. private static _StencilReference;
  59212. /**
  59213. * The name of the component. Each component must have a unique name.
  59214. */
  59215. name: string;
  59216. /**
  59217. * The scene the component belongs to.
  59218. */
  59219. scene: Scene;
  59220. /**
  59221. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59222. */
  59223. zOffset: number;
  59224. private _engine;
  59225. private _effect;
  59226. private _cachedDefines;
  59227. private _savedDepthWrite;
  59228. /**
  59229. * Instantiates a new outline renderer. (There could be only one per scene).
  59230. * @param scene Defines the scene it belongs to
  59231. */
  59232. constructor(scene: Scene);
  59233. /**
  59234. * Register the component to one instance of a scene.
  59235. */
  59236. register(): void;
  59237. /**
  59238. * Rebuilds the elements related to this component in case of
  59239. * context lost for instance.
  59240. */
  59241. rebuild(): void;
  59242. /**
  59243. * Disposes the component and the associated ressources.
  59244. */
  59245. dispose(): void;
  59246. /**
  59247. * Renders the outline in the canvas.
  59248. * @param subMesh Defines the sumesh to render
  59249. * @param batch Defines the batch of meshes in case of instances
  59250. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59251. */
  59252. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59253. /**
  59254. * Returns whether or not the outline renderer is ready for a given submesh.
  59255. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59256. * @param subMesh Defines the submesh to check readyness for
  59257. * @param useInstances Defines wheter wee are trying to render instances or not
  59258. * @returns true if ready otherwise false
  59259. */
  59260. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59261. private _beforeRenderingMesh;
  59262. private _afterRenderingMesh;
  59263. }
  59264. }
  59265. declare module BABYLON {
  59266. /**
  59267. * Defines the list of states available for a task inside a AssetsManager
  59268. */
  59269. export enum AssetTaskState {
  59270. /**
  59271. * Initialization
  59272. */
  59273. INIT = 0,
  59274. /**
  59275. * Running
  59276. */
  59277. RUNNING = 1,
  59278. /**
  59279. * Done
  59280. */
  59281. DONE = 2,
  59282. /**
  59283. * Error
  59284. */
  59285. ERROR = 3
  59286. }
  59287. /**
  59288. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59289. */
  59290. export abstract class AbstractAssetTask {
  59291. /**
  59292. * Task name
  59293. */ name: string;
  59294. /**
  59295. * Callback called when the task is successful
  59296. */
  59297. onSuccess: (task: any) => void;
  59298. /**
  59299. * Callback called when the task is not successful
  59300. */
  59301. onError: (task: any, message?: string, exception?: any) => void;
  59302. /**
  59303. * Creates a new AssetsManager
  59304. * @param name defines the name of the task
  59305. */
  59306. constructor(
  59307. /**
  59308. * Task name
  59309. */ name: string);
  59310. private _isCompleted;
  59311. private _taskState;
  59312. private _errorObject;
  59313. /**
  59314. * Get if the task is completed
  59315. */
  59316. readonly isCompleted: boolean;
  59317. /**
  59318. * Gets the current state of the task
  59319. */
  59320. readonly taskState: AssetTaskState;
  59321. /**
  59322. * Gets the current error object (if task is in error)
  59323. */
  59324. readonly errorObject: {
  59325. message?: string;
  59326. exception?: any;
  59327. };
  59328. /**
  59329. * Internal only
  59330. * @hidden
  59331. */
  59332. _setErrorObject(message?: string, exception?: any): void;
  59333. /**
  59334. * Execute the current task
  59335. * @param scene defines the scene where you want your assets to be loaded
  59336. * @param onSuccess is a callback called when the task is successfully executed
  59337. * @param onError is a callback called if an error occurs
  59338. */
  59339. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59340. /**
  59341. * Execute the current task
  59342. * @param scene defines the scene where you want your assets to be loaded
  59343. * @param onSuccess is a callback called when the task is successfully executed
  59344. * @param onError is a callback called if an error occurs
  59345. */
  59346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59347. /**
  59348. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59349. * This can be used with failed tasks that have the reason for failure fixed.
  59350. */
  59351. reset(): void;
  59352. private onErrorCallback;
  59353. private onDoneCallback;
  59354. }
  59355. /**
  59356. * Define the interface used by progress events raised during assets loading
  59357. */
  59358. export interface IAssetsProgressEvent {
  59359. /**
  59360. * Defines the number of remaining tasks to process
  59361. */
  59362. remainingCount: number;
  59363. /**
  59364. * Defines the total number of tasks
  59365. */
  59366. totalCount: number;
  59367. /**
  59368. * Defines the task that was just processed
  59369. */
  59370. task: AbstractAssetTask;
  59371. }
  59372. /**
  59373. * Class used to share progress information about assets loading
  59374. */
  59375. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59376. /**
  59377. * Defines the number of remaining tasks to process
  59378. */
  59379. remainingCount: number;
  59380. /**
  59381. * Defines the total number of tasks
  59382. */
  59383. totalCount: number;
  59384. /**
  59385. * Defines the task that was just processed
  59386. */
  59387. task: AbstractAssetTask;
  59388. /**
  59389. * Creates a AssetsProgressEvent
  59390. * @param remainingCount defines the number of remaining tasks to process
  59391. * @param totalCount defines the total number of tasks
  59392. * @param task defines the task that was just processed
  59393. */
  59394. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59395. }
  59396. /**
  59397. * Define a task used by AssetsManager to load meshes
  59398. */
  59399. export class MeshAssetTask extends AbstractAssetTask {
  59400. /**
  59401. * Defines the name of the task
  59402. */
  59403. name: string;
  59404. /**
  59405. * Defines the list of mesh's names you want to load
  59406. */
  59407. meshesNames: any;
  59408. /**
  59409. * Defines the root url to use as a base to load your meshes and associated resources
  59410. */
  59411. rootUrl: string;
  59412. /**
  59413. * Defines the filename of the scene to load from
  59414. */
  59415. sceneFilename: string;
  59416. /**
  59417. * Gets the list of loaded meshes
  59418. */
  59419. loadedMeshes: Array<AbstractMesh>;
  59420. /**
  59421. * Gets the list of loaded particle systems
  59422. */
  59423. loadedParticleSystems: Array<IParticleSystem>;
  59424. /**
  59425. * Gets the list of loaded skeletons
  59426. */
  59427. loadedSkeletons: Array<Skeleton>;
  59428. /**
  59429. * Gets the list of loaded animation groups
  59430. */
  59431. loadedAnimationGroups: Array<AnimationGroup>;
  59432. /**
  59433. * Callback called when the task is successful
  59434. */
  59435. onSuccess: (task: MeshAssetTask) => void;
  59436. /**
  59437. * Callback called when the task is successful
  59438. */
  59439. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59440. /**
  59441. * Creates a new MeshAssetTask
  59442. * @param name defines the name of the task
  59443. * @param meshesNames defines the list of mesh's names you want to load
  59444. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59445. * @param sceneFilename defines the filename of the scene to load from
  59446. */
  59447. constructor(
  59448. /**
  59449. * Defines the name of the task
  59450. */
  59451. name: string,
  59452. /**
  59453. * Defines the list of mesh's names you want to load
  59454. */
  59455. meshesNames: any,
  59456. /**
  59457. * Defines the root url to use as a base to load your meshes and associated resources
  59458. */
  59459. rootUrl: string,
  59460. /**
  59461. * Defines the filename of the scene to load from
  59462. */
  59463. sceneFilename: string);
  59464. /**
  59465. * Execute the current task
  59466. * @param scene defines the scene where you want your assets to be loaded
  59467. * @param onSuccess is a callback called when the task is successfully executed
  59468. * @param onError is a callback called if an error occurs
  59469. */
  59470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59471. }
  59472. /**
  59473. * Define a task used by AssetsManager to load text content
  59474. */
  59475. export class TextFileAssetTask extends AbstractAssetTask {
  59476. /**
  59477. * Defines the name of the task
  59478. */
  59479. name: string;
  59480. /**
  59481. * Defines the location of the file to load
  59482. */
  59483. url: string;
  59484. /**
  59485. * Gets the loaded text string
  59486. */
  59487. text: string;
  59488. /**
  59489. * Callback called when the task is successful
  59490. */
  59491. onSuccess: (task: TextFileAssetTask) => void;
  59492. /**
  59493. * Callback called when the task is successful
  59494. */
  59495. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59496. /**
  59497. * Creates a new TextFileAssetTask object
  59498. * @param name defines the name of the task
  59499. * @param url defines the location of the file to load
  59500. */
  59501. constructor(
  59502. /**
  59503. * Defines the name of the task
  59504. */
  59505. name: string,
  59506. /**
  59507. * Defines the location of the file to load
  59508. */
  59509. url: string);
  59510. /**
  59511. * Execute the current task
  59512. * @param scene defines the scene where you want your assets to be loaded
  59513. * @param onSuccess is a callback called when the task is successfully executed
  59514. * @param onError is a callback called if an error occurs
  59515. */
  59516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59517. }
  59518. /**
  59519. * Define a task used by AssetsManager to load binary data
  59520. */
  59521. export class BinaryFileAssetTask extends AbstractAssetTask {
  59522. /**
  59523. * Defines the name of the task
  59524. */
  59525. name: string;
  59526. /**
  59527. * Defines the location of the file to load
  59528. */
  59529. url: string;
  59530. /**
  59531. * Gets the lodaded data (as an array buffer)
  59532. */
  59533. data: ArrayBuffer;
  59534. /**
  59535. * Callback called when the task is successful
  59536. */
  59537. onSuccess: (task: BinaryFileAssetTask) => void;
  59538. /**
  59539. * Callback called when the task is successful
  59540. */
  59541. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59542. /**
  59543. * Creates a new BinaryFileAssetTask object
  59544. * @param name defines the name of the new task
  59545. * @param url defines the location of the file to load
  59546. */
  59547. constructor(
  59548. /**
  59549. * Defines the name of the task
  59550. */
  59551. name: string,
  59552. /**
  59553. * Defines the location of the file to load
  59554. */
  59555. url: string);
  59556. /**
  59557. * Execute the current task
  59558. * @param scene defines the scene where you want your assets to be loaded
  59559. * @param onSuccess is a callback called when the task is successfully executed
  59560. * @param onError is a callback called if an error occurs
  59561. */
  59562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59563. }
  59564. /**
  59565. * Define a task used by AssetsManager to load images
  59566. */
  59567. export class ImageAssetTask extends AbstractAssetTask {
  59568. /**
  59569. * Defines the name of the task
  59570. */
  59571. name: string;
  59572. /**
  59573. * Defines the location of the image to load
  59574. */
  59575. url: string;
  59576. /**
  59577. * Gets the loaded images
  59578. */
  59579. image: HTMLImageElement;
  59580. /**
  59581. * Callback called when the task is successful
  59582. */
  59583. onSuccess: (task: ImageAssetTask) => void;
  59584. /**
  59585. * Callback called when the task is successful
  59586. */
  59587. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59588. /**
  59589. * Creates a new ImageAssetTask
  59590. * @param name defines the name of the task
  59591. * @param url defines the location of the image to load
  59592. */
  59593. constructor(
  59594. /**
  59595. * Defines the name of the task
  59596. */
  59597. name: string,
  59598. /**
  59599. * Defines the location of the image to load
  59600. */
  59601. url: string);
  59602. /**
  59603. * Execute the current task
  59604. * @param scene defines the scene where you want your assets to be loaded
  59605. * @param onSuccess is a callback called when the task is successfully executed
  59606. * @param onError is a callback called if an error occurs
  59607. */
  59608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59609. }
  59610. /**
  59611. * Defines the interface used by texture loading tasks
  59612. */
  59613. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59614. /**
  59615. * Gets the loaded texture
  59616. */
  59617. texture: TEX;
  59618. }
  59619. /**
  59620. * Define a task used by AssetsManager to load 2D textures
  59621. */
  59622. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59623. /**
  59624. * Defines the name of the task
  59625. */
  59626. name: string;
  59627. /**
  59628. * Defines the location of the file to load
  59629. */
  59630. url: string;
  59631. /**
  59632. * Defines if mipmap should not be generated (default is false)
  59633. */
  59634. noMipmap?: boolean | undefined;
  59635. /**
  59636. * Defines if texture must be inverted on Y axis (default is false)
  59637. */
  59638. invertY?: boolean | undefined;
  59639. /**
  59640. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59641. */
  59642. samplingMode: number;
  59643. /**
  59644. * Gets the loaded texture
  59645. */
  59646. texture: Texture;
  59647. /**
  59648. * Callback called when the task is successful
  59649. */
  59650. onSuccess: (task: TextureAssetTask) => void;
  59651. /**
  59652. * Callback called when the task is successful
  59653. */
  59654. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59655. /**
  59656. * Creates a new TextureAssetTask object
  59657. * @param name defines the name of the task
  59658. * @param url defines the location of the file to load
  59659. * @param noMipmap defines if mipmap should not be generated (default is false)
  59660. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59661. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59662. */
  59663. constructor(
  59664. /**
  59665. * Defines the name of the task
  59666. */
  59667. name: string,
  59668. /**
  59669. * Defines the location of the file to load
  59670. */
  59671. url: string,
  59672. /**
  59673. * Defines if mipmap should not be generated (default is false)
  59674. */
  59675. noMipmap?: boolean | undefined,
  59676. /**
  59677. * Defines if texture must be inverted on Y axis (default is false)
  59678. */
  59679. invertY?: boolean | undefined,
  59680. /**
  59681. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59682. */
  59683. samplingMode?: number);
  59684. /**
  59685. * Execute the current task
  59686. * @param scene defines the scene where you want your assets to be loaded
  59687. * @param onSuccess is a callback called when the task is successfully executed
  59688. * @param onError is a callback called if an error occurs
  59689. */
  59690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59691. }
  59692. /**
  59693. * Define a task used by AssetsManager to load cube textures
  59694. */
  59695. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59696. /**
  59697. * Defines the name of the task
  59698. */
  59699. name: string;
  59700. /**
  59701. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59702. */
  59703. url: string;
  59704. /**
  59705. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59706. */
  59707. extensions?: string[] | undefined;
  59708. /**
  59709. * Defines if mipmaps should not be generated (default is false)
  59710. */
  59711. noMipmap?: boolean | undefined;
  59712. /**
  59713. * Defines the explicit list of files (undefined by default)
  59714. */
  59715. files?: string[] | undefined;
  59716. /**
  59717. * Gets the loaded texture
  59718. */
  59719. texture: CubeTexture;
  59720. /**
  59721. * Callback called when the task is successful
  59722. */
  59723. onSuccess: (task: CubeTextureAssetTask) => void;
  59724. /**
  59725. * Callback called when the task is successful
  59726. */
  59727. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59728. /**
  59729. * Creates a new CubeTextureAssetTask
  59730. * @param name defines the name of the task
  59731. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59732. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59733. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59734. * @param files defines the explicit list of files (undefined by default)
  59735. */
  59736. constructor(
  59737. /**
  59738. * Defines the name of the task
  59739. */
  59740. name: string,
  59741. /**
  59742. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59743. */
  59744. url: string,
  59745. /**
  59746. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59747. */
  59748. extensions?: string[] | undefined,
  59749. /**
  59750. * Defines if mipmaps should not be generated (default is false)
  59751. */
  59752. noMipmap?: boolean | undefined,
  59753. /**
  59754. * Defines the explicit list of files (undefined by default)
  59755. */
  59756. files?: string[] | undefined);
  59757. /**
  59758. * Execute the current task
  59759. * @param scene defines the scene where you want your assets to be loaded
  59760. * @param onSuccess is a callback called when the task is successfully executed
  59761. * @param onError is a callback called if an error occurs
  59762. */
  59763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59764. }
  59765. /**
  59766. * Define a task used by AssetsManager to load HDR cube textures
  59767. */
  59768. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  59769. /**
  59770. * Defines the name of the task
  59771. */
  59772. name: string;
  59773. /**
  59774. * Defines the location of the file to load
  59775. */
  59776. url: string;
  59777. /**
  59778. * Defines the desired size (the more it increases the longer the generation will be)
  59779. */
  59780. size: number;
  59781. /**
  59782. * Defines if mipmaps should not be generated (default is false)
  59783. */
  59784. noMipmap: boolean;
  59785. /**
  59786. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59787. */
  59788. generateHarmonics: boolean;
  59789. /**
  59790. * 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)
  59791. */
  59792. gammaSpace: boolean;
  59793. /**
  59794. * Internal Use Only
  59795. */
  59796. reserved: boolean;
  59797. /**
  59798. * Gets the loaded texture
  59799. */
  59800. texture: HDRCubeTexture;
  59801. /**
  59802. * Callback called when the task is successful
  59803. */
  59804. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  59805. /**
  59806. * Callback called when the task is successful
  59807. */
  59808. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  59809. /**
  59810. * Creates a new HDRCubeTextureAssetTask object
  59811. * @param name defines the name of the task
  59812. * @param url defines the location of the file to load
  59813. * @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.
  59814. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59815. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59816. * @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)
  59817. * @param reserved Internal use only
  59818. */
  59819. constructor(
  59820. /**
  59821. * Defines the name of the task
  59822. */
  59823. name: string,
  59824. /**
  59825. * Defines the location of the file to load
  59826. */
  59827. url: string,
  59828. /**
  59829. * Defines the desired size (the more it increases the longer the generation will be)
  59830. */
  59831. size: number,
  59832. /**
  59833. * Defines if mipmaps should not be generated (default is false)
  59834. */
  59835. noMipmap?: boolean,
  59836. /**
  59837. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59838. */
  59839. generateHarmonics?: boolean,
  59840. /**
  59841. * 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)
  59842. */
  59843. gammaSpace?: boolean,
  59844. /**
  59845. * Internal Use Only
  59846. */
  59847. reserved?: boolean);
  59848. /**
  59849. * Execute the current task
  59850. * @param scene defines the scene where you want your assets to be loaded
  59851. * @param onSuccess is a callback called when the task is successfully executed
  59852. * @param onError is a callback called if an error occurs
  59853. */
  59854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59855. }
  59856. /**
  59857. * Define a task used by AssetsManager to load Equirectangular cube textures
  59858. */
  59859. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  59860. /**
  59861. * Defines the name of the task
  59862. */
  59863. name: string;
  59864. /**
  59865. * Defines the location of the file to load
  59866. */
  59867. url: string;
  59868. /**
  59869. * Defines the desired size (the more it increases the longer the generation will be)
  59870. */
  59871. size: number;
  59872. /**
  59873. * Defines if mipmaps should not be generated (default is false)
  59874. */
  59875. noMipmap: boolean;
  59876. /**
  59877. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59878. * but the standard material would require them in Gamma space) (default is true)
  59879. */
  59880. gammaSpace: boolean;
  59881. /**
  59882. * Gets the loaded texture
  59883. */
  59884. texture: EquiRectangularCubeTexture;
  59885. /**
  59886. * Callback called when the task is successful
  59887. */
  59888. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  59889. /**
  59890. * Callback called when the task is successful
  59891. */
  59892. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  59893. /**
  59894. * Creates a new EquiRectangularCubeTextureAssetTask object
  59895. * @param name defines the name of the task
  59896. * @param url defines the location of the file to load
  59897. * @param size defines the desired size (the more it increases the longer the generation will be)
  59898. * If the size is omitted this implies you are using a preprocessed cubemap.
  59899. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59900. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  59901. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59902. * (default is true)
  59903. */
  59904. constructor(
  59905. /**
  59906. * Defines the name of the task
  59907. */
  59908. name: string,
  59909. /**
  59910. * Defines the location of the file to load
  59911. */
  59912. url: string,
  59913. /**
  59914. * Defines the desired size (the more it increases the longer the generation will be)
  59915. */
  59916. size: number,
  59917. /**
  59918. * Defines if mipmaps should not be generated (default is false)
  59919. */
  59920. noMipmap?: boolean,
  59921. /**
  59922. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59923. * but the standard material would require them in Gamma space) (default is true)
  59924. */
  59925. gammaSpace?: boolean);
  59926. /**
  59927. * Execute the current task
  59928. * @param scene defines the scene where you want your assets to be loaded
  59929. * @param onSuccess is a callback called when the task is successfully executed
  59930. * @param onError is a callback called if an error occurs
  59931. */
  59932. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59933. }
  59934. /**
  59935. * This class can be used to easily import assets into a scene
  59936. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  59937. */
  59938. export class AssetsManager {
  59939. private _scene;
  59940. private _isLoading;
  59941. protected _tasks: AbstractAssetTask[];
  59942. protected _waitingTasksCount: number;
  59943. protected _totalTasksCount: number;
  59944. /**
  59945. * Callback called when all tasks are processed
  59946. */
  59947. onFinish: (tasks: AbstractAssetTask[]) => void;
  59948. /**
  59949. * Callback called when a task is successful
  59950. */
  59951. onTaskSuccess: (task: AbstractAssetTask) => void;
  59952. /**
  59953. * Callback called when a task had an error
  59954. */
  59955. onTaskError: (task: AbstractAssetTask) => void;
  59956. /**
  59957. * Callback called when a task is done (whatever the result is)
  59958. */
  59959. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  59960. /**
  59961. * Observable called when all tasks are processed
  59962. */
  59963. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  59964. /**
  59965. * Observable called when a task had an error
  59966. */
  59967. onTaskErrorObservable: Observable<AbstractAssetTask>;
  59968. /**
  59969. * Observable called when all tasks were executed
  59970. */
  59971. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  59972. /**
  59973. * Observable called when a task is done (whatever the result is)
  59974. */
  59975. onProgressObservable: Observable<IAssetsProgressEvent>;
  59976. /**
  59977. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  59978. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  59979. */
  59980. useDefaultLoadingScreen: boolean;
  59981. /**
  59982. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  59983. * when all assets have been downloaded.
  59984. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  59985. */
  59986. autoHideLoadingUI: boolean;
  59987. /**
  59988. * Creates a new AssetsManager
  59989. * @param scene defines the scene to work on
  59990. */
  59991. constructor(scene: Scene);
  59992. /**
  59993. * Add a MeshAssetTask to the list of active tasks
  59994. * @param taskName defines the name of the new task
  59995. * @param meshesNames defines the name of meshes to load
  59996. * @param rootUrl defines the root url to use to locate files
  59997. * @param sceneFilename defines the filename of the scene file
  59998. * @returns a new MeshAssetTask object
  59999. */
  60000. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60001. /**
  60002. * Add a TextFileAssetTask to the list of active tasks
  60003. * @param taskName defines the name of the new task
  60004. * @param url defines the url of the file to load
  60005. * @returns a new TextFileAssetTask object
  60006. */
  60007. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60008. /**
  60009. * Add a BinaryFileAssetTask to the list of active tasks
  60010. * @param taskName defines the name of the new task
  60011. * @param url defines the url of the file to load
  60012. * @returns a new BinaryFileAssetTask object
  60013. */
  60014. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60015. /**
  60016. * Add a ImageAssetTask to the list of active tasks
  60017. * @param taskName defines the name of the new task
  60018. * @param url defines the url of the file to load
  60019. * @returns a new ImageAssetTask object
  60020. */
  60021. addImageTask(taskName: string, url: string): ImageAssetTask;
  60022. /**
  60023. * Add a TextureAssetTask to the list of active tasks
  60024. * @param taskName defines the name of the new task
  60025. * @param url defines the url of the file to load
  60026. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60027. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60028. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60029. * @returns a new TextureAssetTask object
  60030. */
  60031. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60032. /**
  60033. * Add a CubeTextureAssetTask to the list of active tasks
  60034. * @param taskName defines the name of the new task
  60035. * @param url defines the url of the file to load
  60036. * @param extensions defines the extension to use to load the cube map (can be null)
  60037. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60038. * @param files defines the list of files to load (can be null)
  60039. * @returns a new CubeTextureAssetTask object
  60040. */
  60041. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60042. /**
  60043. *
  60044. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60045. * @param taskName defines the name of the new task
  60046. * @param url defines the url of the file to load
  60047. * @param size defines the size you want for the cubemap (can be null)
  60048. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60049. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60050. * @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)
  60051. * @param reserved Internal use only
  60052. * @returns a new HDRCubeTextureAssetTask object
  60053. */
  60054. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60055. /**
  60056. *
  60057. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60058. * @param taskName defines the name of the new task
  60059. * @param url defines the url of the file to load
  60060. * @param size defines the size you want for the cubemap (can be null)
  60061. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60062. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60063. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60064. * @returns a new EquiRectangularCubeTextureAssetTask object
  60065. */
  60066. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60067. /**
  60068. * Remove a task from the assets manager.
  60069. * @param task the task to remove
  60070. */
  60071. removeTask(task: AbstractAssetTask): void;
  60072. private _decreaseWaitingTasksCount;
  60073. private _runTask;
  60074. /**
  60075. * Reset the AssetsManager and remove all tasks
  60076. * @return the current instance of the AssetsManager
  60077. */
  60078. reset(): AssetsManager;
  60079. /**
  60080. * Start the loading process
  60081. * @return the current instance of the AssetsManager
  60082. */
  60083. load(): AssetsManager;
  60084. /**
  60085. * Start the loading process as an async operation
  60086. * @return a promise returning the list of failed tasks
  60087. */
  60088. loadAsync(): Promise<void>;
  60089. }
  60090. }
  60091. declare module BABYLON {
  60092. /**
  60093. * Wrapper class for promise with external resolve and reject.
  60094. */
  60095. export class Deferred<T> {
  60096. /**
  60097. * The promise associated with this deferred object.
  60098. */
  60099. readonly promise: Promise<T>;
  60100. private _resolve;
  60101. private _reject;
  60102. /**
  60103. * The resolve method of the promise associated with this deferred object.
  60104. */
  60105. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60106. /**
  60107. * The reject method of the promise associated with this deferred object.
  60108. */
  60109. readonly reject: (reason?: any) => void;
  60110. /**
  60111. * Constructor for this deferred object.
  60112. */
  60113. constructor();
  60114. }
  60115. }
  60116. declare module BABYLON {
  60117. /**
  60118. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60119. */
  60120. export class MeshExploder {
  60121. private _centerMesh;
  60122. private _meshes;
  60123. private _meshesOrigins;
  60124. private _toCenterVectors;
  60125. private _scaledDirection;
  60126. private _newPosition;
  60127. private _centerPosition;
  60128. /**
  60129. * Explodes meshes from a center mesh.
  60130. * @param meshes The meshes to explode.
  60131. * @param centerMesh The mesh to be center of explosion.
  60132. */
  60133. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60134. private _setCenterMesh;
  60135. /**
  60136. * Get class name
  60137. * @returns "MeshExploder"
  60138. */
  60139. getClassName(): string;
  60140. /**
  60141. * "Exploded meshes"
  60142. * @returns Array of meshes with the centerMesh at index 0.
  60143. */
  60144. getMeshes(): Array<Mesh>;
  60145. /**
  60146. * Explodes meshes giving a specific direction
  60147. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60148. */
  60149. explode(direction?: number): void;
  60150. }
  60151. }
  60152. declare module BABYLON {
  60153. /**
  60154. * Class used to help managing file picking and drag'n'drop
  60155. */
  60156. export class FilesInput {
  60157. /**
  60158. * List of files ready to be loaded
  60159. */
  60160. static readonly FilesToLoad: {
  60161. [key: string]: File;
  60162. };
  60163. /**
  60164. * Callback called when a file is processed
  60165. */
  60166. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60167. private _engine;
  60168. private _currentScene;
  60169. private _sceneLoadedCallback;
  60170. private _progressCallback;
  60171. private _additionalRenderLoopLogicCallback;
  60172. private _textureLoadingCallback;
  60173. private _startingProcessingFilesCallback;
  60174. private _onReloadCallback;
  60175. private _errorCallback;
  60176. private _elementToMonitor;
  60177. private _sceneFileToLoad;
  60178. private _filesToLoad;
  60179. /**
  60180. * Creates a new FilesInput
  60181. * @param engine defines the rendering engine
  60182. * @param scene defines the hosting scene
  60183. * @param sceneLoadedCallback callback called when scene is loaded
  60184. * @param progressCallback callback called to track progress
  60185. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60186. * @param textureLoadingCallback callback called when a texture is loading
  60187. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60188. * @param onReloadCallback callback called when a reload is requested
  60189. * @param errorCallback callback call if an error occurs
  60190. */
  60191. 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);
  60192. private _dragEnterHandler;
  60193. private _dragOverHandler;
  60194. private _dropHandler;
  60195. /**
  60196. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60197. * @param elementToMonitor defines the DOM element to track
  60198. */
  60199. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60200. /**
  60201. * Release all associated resources
  60202. */
  60203. dispose(): void;
  60204. private renderFunction;
  60205. private drag;
  60206. private drop;
  60207. private _traverseFolder;
  60208. private _processFiles;
  60209. /**
  60210. * Load files from a drop event
  60211. * @param event defines the drop event to use as source
  60212. */
  60213. loadFiles(event: any): void;
  60214. private _processReload;
  60215. /**
  60216. * Reload the current scene from the loaded files
  60217. */
  60218. reload(): void;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60225. */
  60226. export class SceneOptimization {
  60227. /**
  60228. * Defines the priority of this optimization (0 by default which means first in the list)
  60229. */
  60230. priority: number;
  60231. /**
  60232. * Gets a string describing the action executed by the current optimization
  60233. * @returns description string
  60234. */
  60235. getDescription(): string;
  60236. /**
  60237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60238. * @param scene defines the current scene where to apply this optimization
  60239. * @param optimizer defines the current optimizer
  60240. * @returns true if everything that can be done was applied
  60241. */
  60242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60243. /**
  60244. * Creates the SceneOptimization object
  60245. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60246. * @param desc defines the description associated with the optimization
  60247. */
  60248. constructor(
  60249. /**
  60250. * Defines the priority of this optimization (0 by default which means first in the list)
  60251. */
  60252. priority?: number);
  60253. }
  60254. /**
  60255. * Defines an optimization used to reduce the size of render target textures
  60256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60257. */
  60258. export class TextureOptimization extends SceneOptimization {
  60259. /**
  60260. * Defines the priority of this optimization (0 by default which means first in the list)
  60261. */
  60262. priority: number;
  60263. /**
  60264. * 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
  60265. */
  60266. maximumSize: number;
  60267. /**
  60268. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60269. */
  60270. step: number;
  60271. /**
  60272. * Gets a string describing the action executed by the current optimization
  60273. * @returns description string
  60274. */
  60275. getDescription(): string;
  60276. /**
  60277. * Creates the TextureOptimization object
  60278. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60279. * @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
  60280. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60281. */
  60282. constructor(
  60283. /**
  60284. * Defines the priority of this optimization (0 by default which means first in the list)
  60285. */
  60286. priority?: number,
  60287. /**
  60288. * 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
  60289. */
  60290. maximumSize?: number,
  60291. /**
  60292. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60293. */
  60294. step?: number);
  60295. /**
  60296. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60297. * @param scene defines the current scene where to apply this optimization
  60298. * @param optimizer defines the current optimizer
  60299. * @returns true if everything that can be done was applied
  60300. */
  60301. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60302. }
  60303. /**
  60304. * Defines an optimization used to increase or decrease the rendering resolution
  60305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60306. */
  60307. export class HardwareScalingOptimization extends SceneOptimization {
  60308. /**
  60309. * Defines the priority of this optimization (0 by default which means first in the list)
  60310. */
  60311. priority: number;
  60312. /**
  60313. * Defines the maximum scale to use (2 by default)
  60314. */
  60315. maximumScale: number;
  60316. /**
  60317. * Defines the step to use between two passes (0.5 by default)
  60318. */
  60319. step: number;
  60320. private _currentScale;
  60321. private _directionOffset;
  60322. /**
  60323. * Gets a string describing the action executed by the current optimization
  60324. * @return description string
  60325. */
  60326. getDescription(): string;
  60327. /**
  60328. * Creates the HardwareScalingOptimization object
  60329. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60330. * @param maximumScale defines the maximum scale to use (2 by default)
  60331. * @param step defines the step to use between two passes (0.5 by default)
  60332. */
  60333. constructor(
  60334. /**
  60335. * Defines the priority of this optimization (0 by default which means first in the list)
  60336. */
  60337. priority?: number,
  60338. /**
  60339. * Defines the maximum scale to use (2 by default)
  60340. */
  60341. maximumScale?: number,
  60342. /**
  60343. * Defines the step to use between two passes (0.5 by default)
  60344. */
  60345. step?: number);
  60346. /**
  60347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60348. * @param scene defines the current scene where to apply this optimization
  60349. * @param optimizer defines the current optimizer
  60350. * @returns true if everything that can be done was applied
  60351. */
  60352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60353. }
  60354. /**
  60355. * Defines an optimization used to remove shadows
  60356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60357. */
  60358. export class ShadowsOptimization extends SceneOptimization {
  60359. /**
  60360. * Gets a string describing the action executed by the current optimization
  60361. * @return description string
  60362. */
  60363. getDescription(): string;
  60364. /**
  60365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60366. * @param scene defines the current scene where to apply this optimization
  60367. * @param optimizer defines the current optimizer
  60368. * @returns true if everything that can be done was applied
  60369. */
  60370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60371. }
  60372. /**
  60373. * Defines an optimization used to turn post-processes off
  60374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60375. */
  60376. export class PostProcessesOptimization extends SceneOptimization {
  60377. /**
  60378. * Gets a string describing the action executed by the current optimization
  60379. * @return description string
  60380. */
  60381. getDescription(): string;
  60382. /**
  60383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60384. * @param scene defines the current scene where to apply this optimization
  60385. * @param optimizer defines the current optimizer
  60386. * @returns true if everything that can be done was applied
  60387. */
  60388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60389. }
  60390. /**
  60391. * Defines an optimization used to turn lens flares off
  60392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60393. */
  60394. export class LensFlaresOptimization extends SceneOptimization {
  60395. /**
  60396. * Gets a string describing the action executed by the current optimization
  60397. * @return description string
  60398. */
  60399. getDescription(): string;
  60400. /**
  60401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60402. * @param scene defines the current scene where to apply this optimization
  60403. * @param optimizer defines the current optimizer
  60404. * @returns true if everything that can be done was applied
  60405. */
  60406. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60407. }
  60408. /**
  60409. * Defines an optimization based on user defined callback.
  60410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60411. */
  60412. export class CustomOptimization extends SceneOptimization {
  60413. /**
  60414. * Callback called to apply the custom optimization.
  60415. */
  60416. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60417. /**
  60418. * Callback called to get custom description
  60419. */
  60420. onGetDescription: () => string;
  60421. /**
  60422. * Gets a string describing the action executed by the current optimization
  60423. * @returns description string
  60424. */
  60425. getDescription(): string;
  60426. /**
  60427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60428. * @param scene defines the current scene where to apply this optimization
  60429. * @param optimizer defines the current optimizer
  60430. * @returns true if everything that can be done was applied
  60431. */
  60432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60433. }
  60434. /**
  60435. * Defines an optimization used to turn particles off
  60436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60437. */
  60438. export class ParticlesOptimization extends SceneOptimization {
  60439. /**
  60440. * Gets a string describing the action executed by the current optimization
  60441. * @return description string
  60442. */
  60443. getDescription(): string;
  60444. /**
  60445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60446. * @param scene defines the current scene where to apply this optimization
  60447. * @param optimizer defines the current optimizer
  60448. * @returns true if everything that can be done was applied
  60449. */
  60450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60451. }
  60452. /**
  60453. * Defines an optimization used to turn render targets off
  60454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60455. */
  60456. export class RenderTargetsOptimization extends SceneOptimization {
  60457. /**
  60458. * Gets a string describing the action executed by the current optimization
  60459. * @return description string
  60460. */
  60461. getDescription(): string;
  60462. /**
  60463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60464. * @param scene defines the current scene where to apply this optimization
  60465. * @param optimizer defines the current optimizer
  60466. * @returns true if everything that can be done was applied
  60467. */
  60468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60469. }
  60470. /**
  60471. * Defines an optimization used to merge meshes with compatible materials
  60472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60473. */
  60474. export class MergeMeshesOptimization extends SceneOptimization {
  60475. private static _UpdateSelectionTree;
  60476. /**
  60477. * Gets or sets a boolean which defines if optimization octree has to be updated
  60478. */
  60479. /**
  60480. * Gets or sets a boolean which defines if optimization octree has to be updated
  60481. */
  60482. static UpdateSelectionTree: boolean;
  60483. /**
  60484. * Gets a string describing the action executed by the current optimization
  60485. * @return description string
  60486. */
  60487. getDescription(): string;
  60488. private _canBeMerged;
  60489. /**
  60490. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60491. * @param scene defines the current scene where to apply this optimization
  60492. * @param optimizer defines the current optimizer
  60493. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60494. * @returns true if everything that can be done was applied
  60495. */
  60496. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60497. }
  60498. /**
  60499. * Defines a list of options used by SceneOptimizer
  60500. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60501. */
  60502. export class SceneOptimizerOptions {
  60503. /**
  60504. * Defines the target frame rate to reach (60 by default)
  60505. */
  60506. targetFrameRate: number;
  60507. /**
  60508. * Defines the interval between two checkes (2000ms by default)
  60509. */
  60510. trackerDuration: number;
  60511. /**
  60512. * Gets the list of optimizations to apply
  60513. */
  60514. optimizations: SceneOptimization[];
  60515. /**
  60516. * Creates a new list of options used by SceneOptimizer
  60517. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60518. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60519. */
  60520. constructor(
  60521. /**
  60522. * Defines the target frame rate to reach (60 by default)
  60523. */
  60524. targetFrameRate?: number,
  60525. /**
  60526. * Defines the interval between two checkes (2000ms by default)
  60527. */
  60528. trackerDuration?: number);
  60529. /**
  60530. * Add a new optimization
  60531. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60532. * @returns the current SceneOptimizerOptions
  60533. */
  60534. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60535. /**
  60536. * Add a new custom optimization
  60537. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60538. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60539. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60540. * @returns the current SceneOptimizerOptions
  60541. */
  60542. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60543. /**
  60544. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60545. * @param targetFrameRate defines the target frame rate (60 by default)
  60546. * @returns a SceneOptimizerOptions object
  60547. */
  60548. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60549. /**
  60550. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60551. * @param targetFrameRate defines the target frame rate (60 by default)
  60552. * @returns a SceneOptimizerOptions object
  60553. */
  60554. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60555. /**
  60556. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60557. * @param targetFrameRate defines the target frame rate (60 by default)
  60558. * @returns a SceneOptimizerOptions object
  60559. */
  60560. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60561. }
  60562. /**
  60563. * Class used to run optimizations in order to reach a target frame rate
  60564. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60565. */
  60566. export class SceneOptimizer implements IDisposable {
  60567. private _isRunning;
  60568. private _options;
  60569. private _scene;
  60570. private _currentPriorityLevel;
  60571. private _targetFrameRate;
  60572. private _trackerDuration;
  60573. private _currentFrameRate;
  60574. private _sceneDisposeObserver;
  60575. private _improvementMode;
  60576. /**
  60577. * Defines an observable called when the optimizer reaches the target frame rate
  60578. */
  60579. onSuccessObservable: Observable<SceneOptimizer>;
  60580. /**
  60581. * Defines an observable called when the optimizer enables an optimization
  60582. */
  60583. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60584. /**
  60585. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60586. */
  60587. onFailureObservable: Observable<SceneOptimizer>;
  60588. /**
  60589. * Gets a boolean indicating if the optimizer is in improvement mode
  60590. */
  60591. readonly isInImprovementMode: boolean;
  60592. /**
  60593. * Gets the current priority level (0 at start)
  60594. */
  60595. readonly currentPriorityLevel: number;
  60596. /**
  60597. * Gets the current frame rate checked by the SceneOptimizer
  60598. */
  60599. readonly currentFrameRate: number;
  60600. /**
  60601. * Gets or sets the current target frame rate (60 by default)
  60602. */
  60603. /**
  60604. * Gets or sets the current target frame rate (60 by default)
  60605. */
  60606. targetFrameRate: number;
  60607. /**
  60608. * Gets or sets the current interval between two checks (every 2000ms by default)
  60609. */
  60610. /**
  60611. * Gets or sets the current interval between two checks (every 2000ms by default)
  60612. */
  60613. trackerDuration: number;
  60614. /**
  60615. * Gets the list of active optimizations
  60616. */
  60617. readonly optimizations: SceneOptimization[];
  60618. /**
  60619. * Creates a new SceneOptimizer
  60620. * @param scene defines the scene to work on
  60621. * @param options defines the options to use with the SceneOptimizer
  60622. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60623. * @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)
  60624. */
  60625. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60626. /**
  60627. * Stops the current optimizer
  60628. */
  60629. stop(): void;
  60630. /**
  60631. * Reset the optimizer to initial step (current priority level = 0)
  60632. */
  60633. reset(): void;
  60634. /**
  60635. * Start the optimizer. By default it will try to reach a specific framerate
  60636. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60637. */
  60638. start(): void;
  60639. private _checkCurrentState;
  60640. /**
  60641. * Release all resources
  60642. */
  60643. dispose(): void;
  60644. /**
  60645. * Helper function to create a SceneOptimizer with one single line of code
  60646. * @param scene defines the scene to work on
  60647. * @param options defines the options to use with the SceneOptimizer
  60648. * @param onSuccess defines a callback to call on success
  60649. * @param onFailure defines a callback to call on failure
  60650. * @returns the new SceneOptimizer object
  60651. */
  60652. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60653. }
  60654. }
  60655. declare module BABYLON {
  60656. /**
  60657. * Class used to serialize a scene into a string
  60658. */
  60659. export class SceneSerializer {
  60660. /**
  60661. * Clear cache used by a previous serialization
  60662. */
  60663. static ClearCache(): void;
  60664. /**
  60665. * Serialize a scene into a JSON compatible object
  60666. * @param scene defines the scene to serialize
  60667. * @returns a JSON compatible object
  60668. */
  60669. static Serialize(scene: Scene): any;
  60670. /**
  60671. * Serialize a mesh into a JSON compatible object
  60672. * @param toSerialize defines the mesh to serialize
  60673. * @param withParents defines if parents must be serialized as well
  60674. * @param withChildren defines if children must be serialized as well
  60675. * @returns a JSON compatible object
  60676. */
  60677. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60678. }
  60679. }
  60680. declare module BABYLON {
  60681. /**
  60682. * Class used to host texture specific utilities
  60683. */
  60684. export class TextureTools {
  60685. /**
  60686. * Uses the GPU to create a copy texture rescaled at a given size
  60687. * @param texture Texture to copy from
  60688. * @param width defines the desired width
  60689. * @param height defines the desired height
  60690. * @param useBilinearMode defines if bilinear mode has to be used
  60691. * @return the generated texture
  60692. */
  60693. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60694. }
  60695. }
  60696. declare module BABYLON {
  60697. /**
  60698. * This represents the different options available for the video capture.
  60699. */
  60700. export interface VideoRecorderOptions {
  60701. /** Defines the mime type of the video. */
  60702. mimeType: string;
  60703. /** Defines the FPS the video should be recorded at. */
  60704. fps: number;
  60705. /** Defines the chunk size for the recording data. */
  60706. recordChunckSize: number;
  60707. /** The audio tracks to attach to the recording. */
  60708. audioTracks?: MediaStreamTrack[];
  60709. }
  60710. /**
  60711. * This can help with recording videos from BabylonJS.
  60712. * This is based on the available WebRTC functionalities of the browser.
  60713. *
  60714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60715. */
  60716. export class VideoRecorder {
  60717. private static readonly _defaultOptions;
  60718. /**
  60719. * Returns whether or not the VideoRecorder is available in your browser.
  60720. * @param engine Defines the Babylon Engine.
  60721. * @returns true if supported otherwise false.
  60722. */
  60723. static IsSupported(engine: Engine): boolean;
  60724. private readonly _options;
  60725. private _canvas;
  60726. private _mediaRecorder;
  60727. private _recordedChunks;
  60728. private _fileName;
  60729. private _resolve;
  60730. private _reject;
  60731. /**
  60732. * True when a recording is already in progress.
  60733. */
  60734. readonly isRecording: boolean;
  60735. /**
  60736. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60737. * @param engine Defines the BabylonJS Engine you wish to record.
  60738. * @param options Defines options that can be used to customize the capture.
  60739. */
  60740. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60741. /**
  60742. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60743. */
  60744. stopRecording(): void;
  60745. /**
  60746. * Starts recording the canvas for a max duration specified in parameters.
  60747. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  60748. * If null no automatic download will start and you can rely on the promise to get the data back.
  60749. * @param maxDuration Defines the maximum recording time in seconds.
  60750. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  60751. * @return A promise callback at the end of the recording with the video data in Blob.
  60752. */
  60753. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  60754. /**
  60755. * Releases internal resources used during the recording.
  60756. */
  60757. dispose(): void;
  60758. private _handleDataAvailable;
  60759. private _handleError;
  60760. private _handleStop;
  60761. }
  60762. }
  60763. declare module BABYLON {
  60764. /**
  60765. * Class containing a set of static utilities functions for screenshots
  60766. */
  60767. export class ScreenshotTools {
  60768. /**
  60769. * Captures a screenshot of the current rendering
  60770. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60771. * @param engine defines the rendering engine
  60772. * @param camera defines the source camera
  60773. * @param size This parameter can be set to a single number or to an object with the
  60774. * following (optional) properties: precision, width, height. If a single number is passed,
  60775. * it will be used for both width and height. If an object is passed, the screenshot size
  60776. * will be derived from the parameters. The precision property is a multiplier allowing
  60777. * rendering at a higher or lower resolution
  60778. * @param successCallback defines the callback receives a single parameter which contains the
  60779. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60780. * src parameter of an <img> to display it
  60781. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60782. * Check your browser for supported MIME types
  60783. */
  60784. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  60785. /**
  60786. * Captures a screenshot of the current rendering
  60787. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60788. * @param engine defines the rendering engine
  60789. * @param camera defines the source camera
  60790. * @param size This parameter can be set to a single number or to an object with the
  60791. * following (optional) properties: precision, width, height. If a single number is passed,
  60792. * it will be used for both width and height. If an object is passed, the screenshot size
  60793. * will be derived from the parameters. The precision property is a multiplier allowing
  60794. * rendering at a higher or lower resolution
  60795. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60796. * Check your browser for supported MIME types
  60797. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60798. * to the src parameter of an <img> to display it
  60799. */
  60800. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  60801. /**
  60802. * Generates an image screenshot from the specified camera.
  60803. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60804. * @param engine The engine to use for rendering
  60805. * @param camera The camera to use for rendering
  60806. * @param size This parameter can be set to a single number or to an object with the
  60807. * following (optional) properties: precision, width, height. If a single number is passed,
  60808. * it will be used for both width and height. If an object is passed, the screenshot size
  60809. * will be derived from the parameters. The precision property is a multiplier allowing
  60810. * rendering at a higher or lower resolution
  60811. * @param successCallback The callback receives a single parameter which contains the
  60812. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60813. * src parameter of an <img> to display it
  60814. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60815. * Check your browser for supported MIME types
  60816. * @param samples Texture samples (default: 1)
  60817. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60818. * @param fileName A name for for the downloaded file.
  60819. */
  60820. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  60821. /**
  60822. * Generates an image screenshot from the specified camera.
  60823. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60824. * @param engine The engine to use for rendering
  60825. * @param camera The camera to use for rendering
  60826. * @param size This parameter can be set to a single number or to an object with the
  60827. * following (optional) properties: precision, width, height. If a single number is passed,
  60828. * it will be used for both width and height. If an object is passed, the screenshot size
  60829. * will be derived from the parameters. The precision property is a multiplier allowing
  60830. * rendering at a higher or lower resolution
  60831. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60832. * Check your browser for supported MIME types
  60833. * @param samples Texture samples (default: 1)
  60834. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60835. * @param fileName A name for for the downloaded file.
  60836. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60837. * to the src parameter of an <img> to display it
  60838. */
  60839. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  60840. /**
  60841. * Gets height and width for screenshot size
  60842. * @private
  60843. */
  60844. private static _getScreenshotSize;
  60845. }
  60846. }
  60847. declare module BABYLON {
  60848. /**
  60849. * A cursor which tracks a point on a path
  60850. */
  60851. export class PathCursor {
  60852. private path;
  60853. /**
  60854. * Stores path cursor callbacks for when an onchange event is triggered
  60855. */
  60856. private _onchange;
  60857. /**
  60858. * The value of the path cursor
  60859. */
  60860. value: number;
  60861. /**
  60862. * The animation array of the path cursor
  60863. */
  60864. animations: Animation[];
  60865. /**
  60866. * Initializes the path cursor
  60867. * @param path The path to track
  60868. */
  60869. constructor(path: Path2);
  60870. /**
  60871. * Gets the cursor point on the path
  60872. * @returns A point on the path cursor at the cursor location
  60873. */
  60874. getPoint(): Vector3;
  60875. /**
  60876. * Moves the cursor ahead by the step amount
  60877. * @param step The amount to move the cursor forward
  60878. * @returns This path cursor
  60879. */
  60880. moveAhead(step?: number): PathCursor;
  60881. /**
  60882. * Moves the cursor behind by the step amount
  60883. * @param step The amount to move the cursor back
  60884. * @returns This path cursor
  60885. */
  60886. moveBack(step?: number): PathCursor;
  60887. /**
  60888. * Moves the cursor by the step amount
  60889. * If the step amount is greater than one, an exception is thrown
  60890. * @param step The amount to move the cursor
  60891. * @returns This path cursor
  60892. */
  60893. move(step: number): PathCursor;
  60894. /**
  60895. * Ensures that the value is limited between zero and one
  60896. * @returns This path cursor
  60897. */
  60898. private ensureLimits;
  60899. /**
  60900. * Runs onchange callbacks on change (used by the animation engine)
  60901. * @returns This path cursor
  60902. */
  60903. private raiseOnChange;
  60904. /**
  60905. * Executes a function on change
  60906. * @param f A path cursor onchange callback
  60907. * @returns This path cursor
  60908. */
  60909. onchange(f: (cursor: PathCursor) => void): PathCursor;
  60910. }
  60911. }
  60912. declare module BABYLON {
  60913. /** @hidden */
  60914. export var blurPixelShader: {
  60915. name: string;
  60916. shader: string;
  60917. };
  60918. }
  60919. declare module BABYLON {
  60920. /** @hidden */
  60921. export var pointCloudVertexDeclaration: {
  60922. name: string;
  60923. shader: string;
  60924. };
  60925. }
  60926. // Mixins
  60927. interface Window {
  60928. mozIndexedDB: IDBFactory;
  60929. webkitIndexedDB: IDBFactory;
  60930. msIndexedDB: IDBFactory;
  60931. webkitURL: typeof URL;
  60932. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  60933. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  60934. WebGLRenderingContext: WebGLRenderingContext;
  60935. MSGesture: MSGesture;
  60936. CANNON: any;
  60937. AudioContext: AudioContext;
  60938. webkitAudioContext: AudioContext;
  60939. PointerEvent: any;
  60940. Math: Math;
  60941. Uint8Array: Uint8ArrayConstructor;
  60942. Float32Array: Float32ArrayConstructor;
  60943. mozURL: typeof URL;
  60944. msURL: typeof URL;
  60945. VRFrameData: any; // WebVR, from specs 1.1
  60946. DracoDecoderModule: any;
  60947. setImmediate(handler: (...args: any[]) => void): number;
  60948. }
  60949. interface HTMLCanvasElement {
  60950. requestPointerLock(): void;
  60951. msRequestPointerLock?(): void;
  60952. mozRequestPointerLock?(): void;
  60953. webkitRequestPointerLock?(): void;
  60954. /** Track wether a record is in progress */
  60955. isRecording: boolean;
  60956. /** Capture Stream method defined by some browsers */
  60957. captureStream(fps?: number): MediaStream;
  60958. }
  60959. interface CanvasRenderingContext2D {
  60960. msImageSmoothingEnabled: boolean;
  60961. }
  60962. interface MouseEvent {
  60963. mozMovementX: number;
  60964. mozMovementY: number;
  60965. webkitMovementX: number;
  60966. webkitMovementY: number;
  60967. msMovementX: number;
  60968. msMovementY: number;
  60969. }
  60970. interface Navigator {
  60971. mozGetVRDevices: (any: any) => any;
  60972. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60973. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60974. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60975. webkitGetGamepads(): Gamepad[];
  60976. msGetGamepads(): Gamepad[];
  60977. webkitGamepads(): Gamepad[];
  60978. }
  60979. interface HTMLVideoElement {
  60980. mozSrcObject: any;
  60981. }
  60982. interface Math {
  60983. fround(x: number): number;
  60984. imul(a: number, b: number): number;
  60985. }
  60986. interface WebGLRenderingContext {
  60987. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  60988. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  60989. vertexAttribDivisor(index: number, divisor: number): void;
  60990. createVertexArray(): any;
  60991. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  60992. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  60993. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  60994. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  60995. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  60996. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  60997. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  60998. // Queries
  60999. createQuery(): WebGLQuery;
  61000. deleteQuery(query: WebGLQuery): void;
  61001. beginQuery(target: number, query: WebGLQuery): void;
  61002. endQuery(target: number): void;
  61003. getQueryParameter(query: WebGLQuery, pname: number): any;
  61004. getQuery(target: number, pname: number): any;
  61005. MAX_SAMPLES: number;
  61006. RGBA8: number;
  61007. READ_FRAMEBUFFER: number;
  61008. DRAW_FRAMEBUFFER: number;
  61009. UNIFORM_BUFFER: number;
  61010. HALF_FLOAT_OES: number;
  61011. RGBA16F: number;
  61012. RGBA32F: number;
  61013. R32F: number;
  61014. RG32F: number;
  61015. RGB32F: number;
  61016. R16F: number;
  61017. RG16F: number;
  61018. RGB16F: number;
  61019. RED: number;
  61020. RG: number;
  61021. R8: number;
  61022. RG8: number;
  61023. UNSIGNED_INT_24_8: number;
  61024. DEPTH24_STENCIL8: number;
  61025. /* Multiple Render Targets */
  61026. drawBuffers(buffers: number[]): void;
  61027. readBuffer(src: number): void;
  61028. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61029. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61030. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61031. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61032. // Occlusion Query
  61033. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61034. ANY_SAMPLES_PASSED: number;
  61035. QUERY_RESULT_AVAILABLE: number;
  61036. QUERY_RESULT: number;
  61037. }
  61038. interface WebGLProgram {
  61039. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61040. }
  61041. interface EXT_disjoint_timer_query {
  61042. QUERY_COUNTER_BITS_EXT: number;
  61043. TIME_ELAPSED_EXT: number;
  61044. TIMESTAMP_EXT: number;
  61045. GPU_DISJOINT_EXT: number;
  61046. QUERY_RESULT_EXT: number;
  61047. QUERY_RESULT_AVAILABLE_EXT: number;
  61048. queryCounterEXT(query: WebGLQuery, target: number): void;
  61049. createQueryEXT(): WebGLQuery;
  61050. beginQueryEXT(target: number, query: WebGLQuery): void;
  61051. endQueryEXT(target: number): void;
  61052. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61053. deleteQueryEXT(query: WebGLQuery): void;
  61054. }
  61055. interface WebGLUniformLocation {
  61056. _currentState: any;
  61057. }
  61058. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61059. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61060. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61061. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61062. interface WebGLRenderingContext {
  61063. readonly RASTERIZER_DISCARD: number;
  61064. readonly DEPTH_COMPONENT24: number;
  61065. readonly TEXTURE_3D: number;
  61066. readonly TEXTURE_2D_ARRAY: number;
  61067. readonly TEXTURE_COMPARE_FUNC: number;
  61068. readonly TEXTURE_COMPARE_MODE: number;
  61069. readonly COMPARE_REF_TO_TEXTURE: number;
  61070. readonly TEXTURE_WRAP_R: number;
  61071. readonly HALF_FLOAT: number;
  61072. readonly RGB8: number;
  61073. readonly RED_INTEGER: number;
  61074. readonly RG_INTEGER: number;
  61075. readonly RGB_INTEGER: number;
  61076. readonly RGBA_INTEGER: number;
  61077. readonly R8_SNORM: number;
  61078. readonly RG8_SNORM: number;
  61079. readonly RGB8_SNORM: number;
  61080. readonly RGBA8_SNORM: number;
  61081. readonly R8I: number;
  61082. readonly RG8I: number;
  61083. readonly RGB8I: number;
  61084. readonly RGBA8I: number;
  61085. readonly R8UI: number;
  61086. readonly RG8UI: number;
  61087. readonly RGB8UI: number;
  61088. readonly RGBA8UI: number;
  61089. readonly R16I: number;
  61090. readonly RG16I: number;
  61091. readonly RGB16I: number;
  61092. readonly RGBA16I: number;
  61093. readonly R16UI: number;
  61094. readonly RG16UI: number;
  61095. readonly RGB16UI: number;
  61096. readonly RGBA16UI: number;
  61097. readonly R32I: number;
  61098. readonly RG32I: number;
  61099. readonly RGB32I: number;
  61100. readonly RGBA32I: number;
  61101. readonly R32UI: number;
  61102. readonly RG32UI: number;
  61103. readonly RGB32UI: number;
  61104. readonly RGBA32UI: number;
  61105. readonly RGB10_A2UI: number;
  61106. readonly R11F_G11F_B10F: number;
  61107. readonly RGB9_E5: number;
  61108. readonly RGB10_A2: number;
  61109. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61110. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61111. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61112. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61113. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61114. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61115. 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;
  61116. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61117. readonly TRANSFORM_FEEDBACK: number;
  61118. readonly INTERLEAVED_ATTRIBS: number;
  61119. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61120. createTransformFeedback(): WebGLTransformFeedback;
  61121. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61122. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61123. beginTransformFeedback(primitiveMode: number): void;
  61124. endTransformFeedback(): void;
  61125. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61126. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61127. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61128. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61129. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61130. }
  61131. interface ImageBitmap {
  61132. readonly width: number;
  61133. readonly height: number;
  61134. close(): void;
  61135. }
  61136. interface WebGLQuery extends WebGLObject {
  61137. }
  61138. declare var WebGLQuery: {
  61139. prototype: WebGLQuery;
  61140. new(): WebGLQuery;
  61141. };
  61142. interface WebGLSampler extends WebGLObject {
  61143. }
  61144. declare var WebGLSampler: {
  61145. prototype: WebGLSampler;
  61146. new(): WebGLSampler;
  61147. };
  61148. interface WebGLSync extends WebGLObject {
  61149. }
  61150. declare var WebGLSync: {
  61151. prototype: WebGLSync;
  61152. new(): WebGLSync;
  61153. };
  61154. interface WebGLTransformFeedback extends WebGLObject {
  61155. }
  61156. declare var WebGLTransformFeedback: {
  61157. prototype: WebGLTransformFeedback;
  61158. new(): WebGLTransformFeedback;
  61159. };
  61160. interface WebGLVertexArrayObject extends WebGLObject {
  61161. }
  61162. declare var WebGLVertexArrayObject: {
  61163. prototype: WebGLVertexArrayObject;
  61164. new(): WebGLVertexArrayObject;
  61165. };
  61166. // Type definitions for WebVR API
  61167. // Project: https://w3c.github.io/webvr/
  61168. // Definitions by: six a <https://github.com/lostfictions>
  61169. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61170. interface VRDisplay extends EventTarget {
  61171. /**
  61172. * Dictionary of capabilities describing the VRDisplay.
  61173. */
  61174. readonly capabilities: VRDisplayCapabilities;
  61175. /**
  61176. * z-depth defining the far plane of the eye view frustum
  61177. * enables mapping of values in the render target depth
  61178. * attachment to scene coordinates. Initially set to 10000.0.
  61179. */
  61180. depthFar: number;
  61181. /**
  61182. * z-depth defining the near plane of the eye view frustum
  61183. * enables mapping of values in the render target depth
  61184. * attachment to scene coordinates. Initially set to 0.01.
  61185. */
  61186. depthNear: number;
  61187. /**
  61188. * An identifier for this distinct VRDisplay. Used as an
  61189. * association point in the Gamepad API.
  61190. */
  61191. readonly displayId: number;
  61192. /**
  61193. * A display name, a user-readable name identifying it.
  61194. */
  61195. readonly displayName: string;
  61196. readonly isConnected: boolean;
  61197. readonly isPresenting: boolean;
  61198. /**
  61199. * If this VRDisplay supports room-scale experiences, the optional
  61200. * stage attribute contains details on the room-scale parameters.
  61201. */
  61202. readonly stageParameters: VRStageParameters | null;
  61203. /**
  61204. * Passing the value returned by `requestAnimationFrame` to
  61205. * `cancelAnimationFrame` will unregister the callback.
  61206. * @param handle Define the hanle of the request to cancel
  61207. */
  61208. cancelAnimationFrame(handle: number): void;
  61209. /**
  61210. * Stops presenting to the VRDisplay.
  61211. * @returns a promise to know when it stopped
  61212. */
  61213. exitPresent(): Promise<void>;
  61214. /**
  61215. * Return the current VREyeParameters for the given eye.
  61216. * @param whichEye Define the eye we want the parameter for
  61217. * @returns the eye parameters
  61218. */
  61219. getEyeParameters(whichEye: string): VREyeParameters;
  61220. /**
  61221. * Populates the passed VRFrameData with the information required to render
  61222. * the current frame.
  61223. * @param frameData Define the data structure to populate
  61224. * @returns true if ok otherwise false
  61225. */
  61226. getFrameData(frameData: VRFrameData): boolean;
  61227. /**
  61228. * Get the layers currently being presented.
  61229. * @returns the list of VR layers
  61230. */
  61231. getLayers(): VRLayer[];
  61232. /**
  61233. * Return a VRPose containing the future predicted pose of the VRDisplay
  61234. * when the current frame will be presented. The value returned will not
  61235. * change until JavaScript has returned control to the browser.
  61236. *
  61237. * The VRPose will contain the position, orientation, velocity,
  61238. * and acceleration of each of these properties.
  61239. * @returns the pose object
  61240. */
  61241. getPose(): VRPose;
  61242. /**
  61243. * Return the current instantaneous pose of the VRDisplay, with no
  61244. * prediction applied.
  61245. * @returns the current instantaneous pose
  61246. */
  61247. getImmediatePose(): VRPose;
  61248. /**
  61249. * The callback passed to `requestAnimationFrame` will be called
  61250. * any time a new frame should be rendered. When the VRDisplay is
  61251. * presenting the callback will be called at the native refresh
  61252. * rate of the HMD. When not presenting this function acts
  61253. * identically to how window.requestAnimationFrame acts. Content should
  61254. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61255. * asynchronously from other displays and at differing refresh rates.
  61256. * @param callback Define the eaction to run next frame
  61257. * @returns the request handle it
  61258. */
  61259. requestAnimationFrame(callback: FrameRequestCallback): number;
  61260. /**
  61261. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61262. * Repeat calls while already presenting will update the VRLayers being displayed.
  61263. * @param layers Define the list of layer to present
  61264. * @returns a promise to know when the request has been fulfilled
  61265. */
  61266. requestPresent(layers: VRLayer[]): Promise<void>;
  61267. /**
  61268. * Reset the pose for this display, treating its current position and
  61269. * orientation as the "origin/zero" values. VRPose.position,
  61270. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61271. * updated when calling resetPose(). This should be called in only
  61272. * sitting-space experiences.
  61273. */
  61274. resetPose(): void;
  61275. /**
  61276. * The VRLayer provided to the VRDisplay will be captured and presented
  61277. * in the HMD. Calling this function has the same effect on the source
  61278. * canvas as any other operation that uses its source image, and canvases
  61279. * created without preserveDrawingBuffer set to true will be cleared.
  61280. * @param pose Define the pose to submit
  61281. */
  61282. submitFrame(pose?: VRPose): void;
  61283. }
  61284. declare var VRDisplay: {
  61285. prototype: VRDisplay;
  61286. new(): VRDisplay;
  61287. };
  61288. interface VRLayer {
  61289. leftBounds?: number[] | Float32Array | null;
  61290. rightBounds?: number[] | Float32Array | null;
  61291. source?: HTMLCanvasElement | null;
  61292. }
  61293. interface VRDisplayCapabilities {
  61294. readonly canPresent: boolean;
  61295. readonly hasExternalDisplay: boolean;
  61296. readonly hasOrientation: boolean;
  61297. readonly hasPosition: boolean;
  61298. readonly maxLayers: number;
  61299. }
  61300. interface VREyeParameters {
  61301. /** @deprecated */
  61302. readonly fieldOfView: VRFieldOfView;
  61303. readonly offset: Float32Array;
  61304. readonly renderHeight: number;
  61305. readonly renderWidth: number;
  61306. }
  61307. interface VRFieldOfView {
  61308. readonly downDegrees: number;
  61309. readonly leftDegrees: number;
  61310. readonly rightDegrees: number;
  61311. readonly upDegrees: number;
  61312. }
  61313. interface VRFrameData {
  61314. readonly leftProjectionMatrix: Float32Array;
  61315. readonly leftViewMatrix: Float32Array;
  61316. readonly pose: VRPose;
  61317. readonly rightProjectionMatrix: Float32Array;
  61318. readonly rightViewMatrix: Float32Array;
  61319. readonly timestamp: number;
  61320. }
  61321. interface VRPose {
  61322. readonly angularAcceleration: Float32Array | null;
  61323. readonly angularVelocity: Float32Array | null;
  61324. readonly linearAcceleration: Float32Array | null;
  61325. readonly linearVelocity: Float32Array | null;
  61326. readonly orientation: Float32Array | null;
  61327. readonly position: Float32Array | null;
  61328. readonly timestamp: number;
  61329. }
  61330. interface VRStageParameters {
  61331. sittingToStandingTransform?: Float32Array;
  61332. sizeX?: number;
  61333. sizeY?: number;
  61334. }
  61335. interface Navigator {
  61336. getVRDisplays(): Promise<VRDisplay[]>;
  61337. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61338. }
  61339. interface Window {
  61340. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61341. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61342. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61343. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61344. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61345. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61346. }
  61347. interface Gamepad {
  61348. readonly displayId: number;
  61349. }
  61350. type XRSessionMode =
  61351. | "inline"
  61352. | "immersive-vr"
  61353. | "immersive-ar";
  61354. type XRReferenceSpaceType =
  61355. | "viewer"
  61356. | "local"
  61357. | "local-floor"
  61358. | "bounded-floor"
  61359. | "unbounded";
  61360. type XREnvironmentBlendMode =
  61361. | "opaque"
  61362. | "additive"
  61363. | "alpha-blend";
  61364. type XRVisibilityState =
  61365. | "visible"
  61366. | "visible-blurred"
  61367. | "hidden";
  61368. type XRHandedness =
  61369. | "none"
  61370. | "left"
  61371. | "right";
  61372. type XRTargetRayMode =
  61373. | "gaze"
  61374. | "tracked-pointer"
  61375. | "screen";
  61376. type XREye =
  61377. | "none"
  61378. | "left"
  61379. | "right";
  61380. interface XRSpace extends EventTarget {
  61381. }
  61382. interface XRRenderState {
  61383. depthNear?: number;
  61384. depthFar?: number;
  61385. inlineVerticalFieldOfView?: number;
  61386. baseLayer?: XRWebGLLayer;
  61387. }
  61388. interface XRInputSource {
  61389. handedness: XRHandedness;
  61390. targetRayMode: XRTargetRayMode;
  61391. targetRaySpace: XRSpace;
  61392. gripSpace: XRSpace | undefined;
  61393. gamepad: Gamepad | undefined;
  61394. profiles: Array<string>;
  61395. }
  61396. interface XRSession {
  61397. addEventListener: Function;
  61398. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61399. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61400. requestAnimationFrame: Function;
  61401. end(): Promise<void>;
  61402. renderState: XRRenderState;
  61403. inputSources: Array<XRInputSource>;
  61404. }
  61405. interface XRReferenceSpace extends XRSpace {
  61406. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61407. onreset: any;
  61408. }
  61409. interface XRFrame {
  61410. session: XRSession;
  61411. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61412. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61413. }
  61414. interface XRViewerPose extends XRPose {
  61415. views: Array<XRView>;
  61416. }
  61417. interface XRPose {
  61418. transform: XRRigidTransform;
  61419. emulatedPosition: boolean;
  61420. }
  61421. declare var XRWebGLLayer: {
  61422. prototype: XRWebGLLayer;
  61423. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61424. };
  61425. interface XRWebGLLayer {
  61426. framebuffer: WebGLFramebuffer;
  61427. framebufferWidth: number;
  61428. framebufferHeight: number;
  61429. getViewport: Function;
  61430. }
  61431. interface XRRigidTransform {
  61432. position: DOMPointReadOnly;
  61433. orientation: DOMPointReadOnly;
  61434. matrix: Float32Array;
  61435. inverse: XRRigidTransform;
  61436. }
  61437. interface XRView {
  61438. eye: XREye;
  61439. projectionMatrix: Float32Array;
  61440. transform: XRRigidTransform;
  61441. }
  61442. interface XRInputSourceChangeEvent {
  61443. session: XRSession;
  61444. removed: Array<XRInputSource>;
  61445. added: Array<XRInputSource>;
  61446. }
  61447. declare module BABYLON.GUI {
  61448. /**
  61449. * Class used to specific a value and its associated unit
  61450. */
  61451. export class ValueAndUnit {
  61452. /** defines the unit to store */
  61453. unit: number;
  61454. /** defines a boolean indicating if the value can be negative */
  61455. negativeValueAllowed: boolean;
  61456. private _value;
  61457. private _originalUnit;
  61458. /**
  61459. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61460. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61461. */
  61462. ignoreAdaptiveScaling: boolean;
  61463. /**
  61464. * Creates a new ValueAndUnit
  61465. * @param value defines the value to store
  61466. * @param unit defines the unit to store
  61467. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61468. */
  61469. constructor(value: number,
  61470. /** defines the unit to store */
  61471. unit?: number,
  61472. /** defines a boolean indicating if the value can be negative */
  61473. negativeValueAllowed?: boolean);
  61474. /** Gets a boolean indicating if the value is a percentage */
  61475. readonly isPercentage: boolean;
  61476. /** Gets a boolean indicating if the value is store as pixel */
  61477. readonly isPixel: boolean;
  61478. /** Gets direct internal value */
  61479. readonly internalValue: number;
  61480. /**
  61481. * Gets value as pixel
  61482. * @param host defines the root host
  61483. * @param refValue defines the reference value for percentages
  61484. * @returns the value as pixel
  61485. */
  61486. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61487. /**
  61488. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61489. * @param value defines the value to store
  61490. * @param unit defines the unit to store
  61491. * @returns the current ValueAndUnit
  61492. */
  61493. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61494. /**
  61495. * Gets the value accordingly to its unit
  61496. * @param host defines the root host
  61497. * @returns the value
  61498. */
  61499. getValue(host: AdvancedDynamicTexture): number;
  61500. /**
  61501. * Gets a string representation of the value
  61502. * @param host defines the root host
  61503. * @param decimals defines an optional number of decimals to display
  61504. * @returns a string
  61505. */
  61506. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61507. /**
  61508. * Store a value parsed from a string
  61509. * @param source defines the source string
  61510. * @returns true if the value was successfully parsed
  61511. */
  61512. fromString(source: string | number): boolean;
  61513. private static _Regex;
  61514. private static _UNITMODE_PERCENTAGE;
  61515. private static _UNITMODE_PIXEL;
  61516. /** UNITMODE_PERCENTAGE */
  61517. static readonly UNITMODE_PERCENTAGE: number;
  61518. /** UNITMODE_PIXEL */
  61519. static readonly UNITMODE_PIXEL: number;
  61520. }
  61521. }
  61522. declare module BABYLON.GUI {
  61523. /**
  61524. * Define a style used by control to automatically setup properties based on a template.
  61525. * Only support font related properties so far
  61526. */
  61527. export class Style implements BABYLON.IDisposable {
  61528. private _fontFamily;
  61529. private _fontStyle;
  61530. private _fontWeight;
  61531. /** @hidden */
  61532. _host: AdvancedDynamicTexture;
  61533. /** @hidden */
  61534. _fontSize: ValueAndUnit;
  61535. /**
  61536. * BABYLON.Observable raised when the style values are changed
  61537. */
  61538. onChangedObservable: BABYLON.Observable<Style>;
  61539. /**
  61540. * Creates a new style object
  61541. * @param host defines the AdvancedDynamicTexture which hosts this style
  61542. */
  61543. constructor(host: AdvancedDynamicTexture);
  61544. /**
  61545. * Gets or sets the font size
  61546. */
  61547. fontSize: string | number;
  61548. /**
  61549. * Gets or sets the font family
  61550. */
  61551. fontFamily: string;
  61552. /**
  61553. * Gets or sets the font style
  61554. */
  61555. fontStyle: string;
  61556. /** Gets or sets font weight */
  61557. fontWeight: string;
  61558. /** Dispose all associated resources */
  61559. dispose(): void;
  61560. }
  61561. }
  61562. declare module BABYLON.GUI {
  61563. /**
  61564. * Class used to transport BABYLON.Vector2 information for pointer events
  61565. */
  61566. export class Vector2WithInfo extends BABYLON.Vector2 {
  61567. /** defines the current mouse button index */
  61568. buttonIndex: number;
  61569. /**
  61570. * Creates a new Vector2WithInfo
  61571. * @param source defines the vector2 data to transport
  61572. * @param buttonIndex defines the current mouse button index
  61573. */
  61574. constructor(source: BABYLON.Vector2,
  61575. /** defines the current mouse button index */
  61576. buttonIndex?: number);
  61577. }
  61578. /** Class used to provide 2D matrix features */
  61579. export class Matrix2D {
  61580. /** Gets the internal array of 6 floats used to store matrix data */
  61581. m: Float32Array;
  61582. /**
  61583. * Creates a new matrix
  61584. * @param m00 defines value for (0, 0)
  61585. * @param m01 defines value for (0, 1)
  61586. * @param m10 defines value for (1, 0)
  61587. * @param m11 defines value for (1, 1)
  61588. * @param m20 defines value for (2, 0)
  61589. * @param m21 defines value for (2, 1)
  61590. */
  61591. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61592. /**
  61593. * Fills the matrix from direct values
  61594. * @param m00 defines value for (0, 0)
  61595. * @param m01 defines value for (0, 1)
  61596. * @param m10 defines value for (1, 0)
  61597. * @param m11 defines value for (1, 1)
  61598. * @param m20 defines value for (2, 0)
  61599. * @param m21 defines value for (2, 1)
  61600. * @returns the current modified matrix
  61601. */
  61602. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61603. /**
  61604. * Gets matrix determinant
  61605. * @returns the determinant
  61606. */
  61607. determinant(): number;
  61608. /**
  61609. * Inverses the matrix and stores it in a target matrix
  61610. * @param result defines the target matrix
  61611. * @returns the current matrix
  61612. */
  61613. invertToRef(result: Matrix2D): Matrix2D;
  61614. /**
  61615. * Multiplies the current matrix with another one
  61616. * @param other defines the second operand
  61617. * @param result defines the target matrix
  61618. * @returns the current matrix
  61619. */
  61620. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61621. /**
  61622. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61623. * @param x defines the x coordinate to transform
  61624. * @param y defines the x coordinate to transform
  61625. * @param result defines the target vector2
  61626. * @returns the current matrix
  61627. */
  61628. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61629. /**
  61630. * Creates an identity matrix
  61631. * @returns a new matrix
  61632. */
  61633. static Identity(): Matrix2D;
  61634. /**
  61635. * Creates a translation matrix and stores it in a target matrix
  61636. * @param x defines the x coordinate of the translation
  61637. * @param y defines the y coordinate of the translation
  61638. * @param result defines the target matrix
  61639. */
  61640. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61641. /**
  61642. * Creates a scaling matrix and stores it in a target matrix
  61643. * @param x defines the x coordinate of the scaling
  61644. * @param y defines the y coordinate of the scaling
  61645. * @param result defines the target matrix
  61646. */
  61647. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61648. /**
  61649. * Creates a rotation matrix and stores it in a target matrix
  61650. * @param angle defines the rotation angle
  61651. * @param result defines the target matrix
  61652. */
  61653. static RotationToRef(angle: number, result: Matrix2D): void;
  61654. private static _TempPreTranslationMatrix;
  61655. private static _TempPostTranslationMatrix;
  61656. private static _TempRotationMatrix;
  61657. private static _TempScalingMatrix;
  61658. private static _TempCompose0;
  61659. private static _TempCompose1;
  61660. private static _TempCompose2;
  61661. /**
  61662. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61663. * @param tx defines the x coordinate of the translation
  61664. * @param ty defines the y coordinate of the translation
  61665. * @param angle defines the rotation angle
  61666. * @param scaleX defines the x coordinate of the scaling
  61667. * @param scaleY defines the y coordinate of the scaling
  61668. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61669. * @param result defines the target matrix
  61670. */
  61671. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61672. }
  61673. }
  61674. declare module BABYLON.GUI {
  61675. /**
  61676. * Class used to store 2D control sizes
  61677. */
  61678. export class Measure {
  61679. /** defines left coordinate */
  61680. left: number;
  61681. /** defines top coordinate */
  61682. top: number;
  61683. /** defines width dimension */
  61684. width: number;
  61685. /** defines height dimension */
  61686. height: number;
  61687. /**
  61688. * Creates a new measure
  61689. * @param left defines left coordinate
  61690. * @param top defines top coordinate
  61691. * @param width defines width dimension
  61692. * @param height defines height dimension
  61693. */
  61694. constructor(
  61695. /** defines left coordinate */
  61696. left: number,
  61697. /** defines top coordinate */
  61698. top: number,
  61699. /** defines width dimension */
  61700. width: number,
  61701. /** defines height dimension */
  61702. height: number);
  61703. /**
  61704. * Copy from another measure
  61705. * @param other defines the other measure to copy from
  61706. */
  61707. copyFrom(other: Measure): void;
  61708. /**
  61709. * Copy from a group of 4 floats
  61710. * @param left defines left coordinate
  61711. * @param top defines top coordinate
  61712. * @param width defines width dimension
  61713. * @param height defines height dimension
  61714. */
  61715. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61716. /**
  61717. * Computes the axis aligned bounding box measure for two given measures
  61718. * @param a Input measure
  61719. * @param b Input measure
  61720. * @param result the resulting bounding measure
  61721. */
  61722. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61723. /**
  61724. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61725. * @param transform the matrix to transform the measure before computing the AABB
  61726. * @param result the resulting AABB
  61727. */
  61728. transformToRef(transform: Matrix2D, result: Measure): void;
  61729. /**
  61730. * Check equality between this measure and another one
  61731. * @param other defines the other measures
  61732. * @returns true if both measures are equals
  61733. */
  61734. isEqualsTo(other: Measure): boolean;
  61735. /**
  61736. * Creates an empty measure
  61737. * @returns a new measure
  61738. */
  61739. static Empty(): Measure;
  61740. }
  61741. }
  61742. declare module BABYLON.GUI {
  61743. /**
  61744. * Interface used to define a control that can receive focus
  61745. */
  61746. export interface IFocusableControl {
  61747. /**
  61748. * Function called when the control receives the focus
  61749. */
  61750. onFocus(): void;
  61751. /**
  61752. * Function called when the control loses the focus
  61753. */
  61754. onBlur(): void;
  61755. /**
  61756. * Function called to let the control handle keyboard events
  61757. * @param evt defines the current keyboard event
  61758. */
  61759. processKeyboard(evt: KeyboardEvent): void;
  61760. /**
  61761. * Function called to get the list of controls that should not steal the focus from this control
  61762. * @returns an array of controls
  61763. */
  61764. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61765. }
  61766. /**
  61767. * Class used to create texture to support 2D GUI elements
  61768. * @see http://doc.babylonjs.com/how_to/gui
  61769. */
  61770. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  61771. private _isDirty;
  61772. private _renderObserver;
  61773. private _resizeObserver;
  61774. private _preKeyboardObserver;
  61775. private _pointerMoveObserver;
  61776. private _pointerObserver;
  61777. private _canvasPointerOutObserver;
  61778. private _background;
  61779. /** @hidden */
  61780. _rootContainer: Container;
  61781. /** @hidden */
  61782. _lastPickedControl: Control;
  61783. /** @hidden */
  61784. _lastControlOver: {
  61785. [pointerId: number]: Control;
  61786. };
  61787. /** @hidden */
  61788. _lastControlDown: {
  61789. [pointerId: number]: Control;
  61790. };
  61791. /** @hidden */
  61792. _capturingControl: {
  61793. [pointerId: number]: Control;
  61794. };
  61795. /** @hidden */
  61796. _shouldBlockPointer: boolean;
  61797. /** @hidden */
  61798. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  61799. /** @hidden */
  61800. _linkedControls: Control[];
  61801. private _isFullscreen;
  61802. private _fullscreenViewport;
  61803. private _idealWidth;
  61804. private _idealHeight;
  61805. private _useSmallestIdeal;
  61806. private _renderAtIdealSize;
  61807. private _focusedControl;
  61808. private _blockNextFocusCheck;
  61809. private _renderScale;
  61810. private _rootCanvas;
  61811. private _cursorChanged;
  61812. /**
  61813. * Define type to string to ensure compatibility across browsers
  61814. * Safari doesn't support DataTransfer constructor
  61815. */
  61816. private _clipboardData;
  61817. /**
  61818. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  61819. */
  61820. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  61821. /**
  61822. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  61823. */
  61824. onControlPickedObservable: BABYLON.Observable<Control>;
  61825. /**
  61826. * BABYLON.Observable event triggered before layout is evaluated
  61827. */
  61828. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61829. /**
  61830. * BABYLON.Observable event triggered after the layout was evaluated
  61831. */
  61832. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61833. /**
  61834. * BABYLON.Observable event triggered before the texture is rendered
  61835. */
  61836. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61837. /**
  61838. * BABYLON.Observable event triggered after the texture was rendered
  61839. */
  61840. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61841. /**
  61842. * Gets or sets a boolean defining if alpha is stored as premultiplied
  61843. */
  61844. premulAlpha: boolean;
  61845. /**
  61846. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  61847. * Useful when you want more antialiasing
  61848. */
  61849. renderScale: number;
  61850. /** Gets or sets the background color */
  61851. background: string;
  61852. /**
  61853. * Gets or sets the ideal width used to design controls.
  61854. * The GUI will then rescale everything accordingly
  61855. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61856. */
  61857. idealWidth: number;
  61858. /**
  61859. * Gets or sets the ideal height used to design controls.
  61860. * The GUI will then rescale everything accordingly
  61861. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61862. */
  61863. idealHeight: number;
  61864. /**
  61865. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  61866. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61867. */
  61868. useSmallestIdeal: boolean;
  61869. /**
  61870. * Gets or sets a boolean indicating if adaptive scaling must be used
  61871. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61872. */
  61873. renderAtIdealSize: boolean;
  61874. /**
  61875. * Gets the underlying layer used to render the texture when in fullscreen mode
  61876. */
  61877. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  61878. /**
  61879. * Gets the root container control
  61880. */
  61881. readonly rootContainer: Container;
  61882. /**
  61883. * Returns an array containing the root container.
  61884. * This is mostly used to let the Inspector introspects the ADT
  61885. * @returns an array containing the rootContainer
  61886. */
  61887. getChildren(): Array<Container>;
  61888. /**
  61889. * Will return all controls that are inside this texture
  61890. * @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
  61891. * @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
  61892. * @return all child controls
  61893. */
  61894. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61895. /**
  61896. * Gets or sets the current focused control
  61897. */
  61898. focusedControl: BABYLON.Nullable<IFocusableControl>;
  61899. /**
  61900. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  61901. */
  61902. isForeground: boolean;
  61903. /**
  61904. * Gets or set information about clipboardData
  61905. */
  61906. clipboardData: string;
  61907. /**
  61908. * Creates a new AdvancedDynamicTexture
  61909. * @param name defines the name of the texture
  61910. * @param width defines the width of the texture
  61911. * @param height defines the height of the texture
  61912. * @param scene defines the hosting scene
  61913. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  61914. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  61915. */
  61916. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  61917. /**
  61918. * Get the current class name of the texture useful for serialization or dynamic coding.
  61919. * @returns "AdvancedDynamicTexture"
  61920. */
  61921. getClassName(): string;
  61922. /**
  61923. * Function used to execute a function on all controls
  61924. * @param func defines the function to execute
  61925. * @param container defines the container where controls belong. If null the root container will be used
  61926. */
  61927. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  61928. private _useInvalidateRectOptimization;
  61929. /**
  61930. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  61931. */
  61932. useInvalidateRectOptimization: boolean;
  61933. private _invalidatedRectangle;
  61934. /**
  61935. * Invalidates a rectangle area on the gui texture
  61936. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  61937. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  61938. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  61939. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  61940. */
  61941. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  61942. /**
  61943. * Marks the texture as dirty forcing a complete update
  61944. */
  61945. markAsDirty(): void;
  61946. /**
  61947. * Helper function used to create a new style
  61948. * @returns a new style
  61949. * @see http://doc.babylonjs.com/how_to/gui#styles
  61950. */
  61951. createStyle(): Style;
  61952. /**
  61953. * Adds a new control to the root container
  61954. * @param control defines the control to add
  61955. * @returns the current texture
  61956. */
  61957. addControl(control: Control): AdvancedDynamicTexture;
  61958. /**
  61959. * Removes a control from the root container
  61960. * @param control defines the control to remove
  61961. * @returns the current texture
  61962. */
  61963. removeControl(control: Control): AdvancedDynamicTexture;
  61964. /**
  61965. * Release all resources
  61966. */
  61967. dispose(): void;
  61968. private _onResize;
  61969. /** @hidden */
  61970. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  61971. /**
  61972. * Get screen coordinates for a vector3
  61973. * @param position defines the position to project
  61974. * @param worldMatrix defines the world matrix to use
  61975. * @returns the projected position
  61976. */
  61977. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  61978. private _checkUpdate;
  61979. private _clearMeasure;
  61980. private _render;
  61981. /** @hidden */
  61982. _changeCursor(cursor: string): void;
  61983. /** @hidden */
  61984. _registerLastControlDown(control: Control, pointerId: number): void;
  61985. private _doPicking;
  61986. /** @hidden */
  61987. _cleanControlAfterRemovalFromList(list: {
  61988. [pointerId: number]: Control;
  61989. }, control: Control): void;
  61990. /** @hidden */
  61991. _cleanControlAfterRemoval(control: Control): void;
  61992. /** Attach to all scene events required to support pointer events */
  61993. attach(): void;
  61994. /** @hidden */
  61995. private onClipboardCopy;
  61996. /** @hidden */
  61997. private onClipboardCut;
  61998. /** @hidden */
  61999. private onClipboardPaste;
  62000. /**
  62001. * Register the clipboard Events onto the canvas
  62002. */
  62003. registerClipboardEvents(): void;
  62004. /**
  62005. * Unregister the clipboard Events from the canvas
  62006. */
  62007. unRegisterClipboardEvents(): void;
  62008. /**
  62009. * Connect the texture to a hosting mesh to enable interactions
  62010. * @param mesh defines the mesh to attach to
  62011. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62012. */
  62013. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62014. /**
  62015. * Move the focus to a specific control
  62016. * @param control defines the control which will receive the focus
  62017. */
  62018. moveFocusToControl(control: IFocusableControl): void;
  62019. private _manageFocus;
  62020. private _attachToOnPointerOut;
  62021. /**
  62022. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62023. * @param mesh defines the mesh which will receive the texture
  62024. * @param width defines the texture width (1024 by default)
  62025. * @param height defines the texture height (1024 by default)
  62026. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62027. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62028. * @returns a new AdvancedDynamicTexture
  62029. */
  62030. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62031. /**
  62032. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62033. * In this mode the texture will rely on a layer for its rendering.
  62034. * This allows it to be treated like any other layer.
  62035. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62036. * LayerMask is set through advancedTexture.layer.layerMask
  62037. * @param name defines name for the texture
  62038. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62039. * @param scene defines the hsoting scene
  62040. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62041. * @returns a new AdvancedDynamicTexture
  62042. */
  62043. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62044. }
  62045. }
  62046. declare module BABYLON.GUI {
  62047. /**
  62048. * Root class used for all 2D controls
  62049. * @see http://doc.babylonjs.com/how_to/gui#controls
  62050. */
  62051. export class Control {
  62052. /** defines the name of the control */
  62053. name?: string | undefined;
  62054. /**
  62055. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62056. */
  62057. static AllowAlphaInheritance: boolean;
  62058. private _alpha;
  62059. private _alphaSet;
  62060. private _zIndex;
  62061. /** @hidden */
  62062. _host: AdvancedDynamicTexture;
  62063. /** Gets or sets the control parent */
  62064. parent: BABYLON.Nullable<Container>;
  62065. /** @hidden */
  62066. _currentMeasure: Measure;
  62067. private _fontFamily;
  62068. private _fontStyle;
  62069. private _fontWeight;
  62070. private _fontSize;
  62071. private _font;
  62072. /** @hidden */
  62073. _width: ValueAndUnit;
  62074. /** @hidden */
  62075. _height: ValueAndUnit;
  62076. /** @hidden */
  62077. protected _fontOffset: {
  62078. ascent: number;
  62079. height: number;
  62080. descent: number;
  62081. };
  62082. private _color;
  62083. private _style;
  62084. private _styleObserver;
  62085. /** @hidden */
  62086. protected _horizontalAlignment: number;
  62087. /** @hidden */
  62088. protected _verticalAlignment: number;
  62089. /** @hidden */
  62090. protected _isDirty: boolean;
  62091. /** @hidden */
  62092. protected _wasDirty: boolean;
  62093. /** @hidden */
  62094. _tempParentMeasure: Measure;
  62095. /** @hidden */
  62096. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62097. /** @hidden */
  62098. protected _cachedParentMeasure: Measure;
  62099. private _paddingLeft;
  62100. private _paddingRight;
  62101. private _paddingTop;
  62102. private _paddingBottom;
  62103. /** @hidden */
  62104. _left: ValueAndUnit;
  62105. /** @hidden */
  62106. _top: ValueAndUnit;
  62107. private _scaleX;
  62108. private _scaleY;
  62109. private _rotation;
  62110. private _transformCenterX;
  62111. private _transformCenterY;
  62112. /** @hidden */
  62113. _transformMatrix: Matrix2D;
  62114. /** @hidden */
  62115. protected _invertTransformMatrix: Matrix2D;
  62116. /** @hidden */
  62117. protected _transformedPosition: BABYLON.Vector2;
  62118. private _isMatrixDirty;
  62119. private _cachedOffsetX;
  62120. private _cachedOffsetY;
  62121. private _isVisible;
  62122. private _isHighlighted;
  62123. /** @hidden */
  62124. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62125. private _fontSet;
  62126. private _dummyVector2;
  62127. private _downCount;
  62128. private _enterCount;
  62129. private _doNotRender;
  62130. private _downPointerIds;
  62131. protected _isEnabled: boolean;
  62132. protected _disabledColor: string;
  62133. /** @hidden */
  62134. protected _rebuildLayout: boolean;
  62135. /** @hidden */
  62136. _isClipped: boolean;
  62137. /** @hidden */
  62138. _tag: any;
  62139. /**
  62140. * 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
  62141. */
  62142. uniqueId: number;
  62143. /**
  62144. * Gets or sets an object used to store user defined information for the node
  62145. */
  62146. metadata: any;
  62147. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62148. isHitTestVisible: boolean;
  62149. /** Gets or sets a boolean indicating if the control can block pointer events */
  62150. isPointerBlocker: boolean;
  62151. /** Gets or sets a boolean indicating if the control can be focusable */
  62152. isFocusInvisible: boolean;
  62153. /**
  62154. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62155. * 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
  62156. */
  62157. clipChildren: boolean;
  62158. /**
  62159. * Gets or sets a boolean indicating that control content must be clipped
  62160. * 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
  62161. */
  62162. clipContent: boolean;
  62163. /**
  62164. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62165. */
  62166. useBitmapCache: boolean;
  62167. private _cacheData;
  62168. private _shadowOffsetX;
  62169. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62170. shadowOffsetX: number;
  62171. private _shadowOffsetY;
  62172. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62173. shadowOffsetY: number;
  62174. private _shadowBlur;
  62175. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62176. shadowBlur: number;
  62177. private _shadowColor;
  62178. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62179. shadowColor: string;
  62180. /** Gets or sets the cursor to use when the control is hovered */
  62181. hoverCursor: string;
  62182. /** @hidden */
  62183. protected _linkOffsetX: ValueAndUnit;
  62184. /** @hidden */
  62185. protected _linkOffsetY: ValueAndUnit;
  62186. /** Gets the control type name */
  62187. readonly typeName: string;
  62188. /**
  62189. * Get the current class name of the control.
  62190. * @returns current class name
  62191. */
  62192. getClassName(): string;
  62193. /**
  62194. * An event triggered when the pointer move over the control.
  62195. */
  62196. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62197. /**
  62198. * An event triggered when the pointer move out of the control.
  62199. */
  62200. onPointerOutObservable: BABYLON.Observable<Control>;
  62201. /**
  62202. * An event triggered when the pointer taps the control
  62203. */
  62204. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62205. /**
  62206. * An event triggered when pointer up
  62207. */
  62208. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62209. /**
  62210. * An event triggered when a control is clicked on
  62211. */
  62212. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62213. /**
  62214. * An event triggered when pointer enters the control
  62215. */
  62216. onPointerEnterObservable: BABYLON.Observable<Control>;
  62217. /**
  62218. * An event triggered when the control is marked as dirty
  62219. */
  62220. onDirtyObservable: BABYLON.Observable<Control>;
  62221. /**
  62222. * An event triggered before drawing the control
  62223. */
  62224. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62225. /**
  62226. * An event triggered after the control was drawn
  62227. */
  62228. onAfterDrawObservable: BABYLON.Observable<Control>;
  62229. /**
  62230. * Get the hosting AdvancedDynamicTexture
  62231. */
  62232. readonly host: AdvancedDynamicTexture;
  62233. /** Gets or set information about font offsets (used to render and align text) */
  62234. fontOffset: {
  62235. ascent: number;
  62236. height: number;
  62237. descent: number;
  62238. };
  62239. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62240. alpha: number;
  62241. /**
  62242. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62243. */
  62244. isHighlighted: boolean;
  62245. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62246. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62247. */
  62248. scaleX: number;
  62249. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62250. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62251. */
  62252. scaleY: number;
  62253. /** Gets or sets the rotation angle (0 by default)
  62254. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62255. */
  62256. rotation: number;
  62257. /** Gets or sets the transformation center on Y axis (0 by default)
  62258. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62259. */
  62260. transformCenterY: number;
  62261. /** Gets or sets the transformation center on X axis (0 by default)
  62262. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62263. */
  62264. transformCenterX: number;
  62265. /**
  62266. * Gets or sets the horizontal alignment
  62267. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62268. */
  62269. horizontalAlignment: number;
  62270. /**
  62271. * Gets or sets the vertical alignment
  62272. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62273. */
  62274. verticalAlignment: number;
  62275. /**
  62276. * Gets or sets control width
  62277. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62278. */
  62279. width: string | number;
  62280. /**
  62281. * Gets or sets the control width in pixel
  62282. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62283. */
  62284. widthInPixels: number;
  62285. /**
  62286. * Gets or sets control height
  62287. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62288. */
  62289. height: string | number;
  62290. /**
  62291. * Gets or sets control height in pixel
  62292. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62293. */
  62294. heightInPixels: number;
  62295. /** Gets or set font family */
  62296. fontFamily: string;
  62297. /** Gets or sets font style */
  62298. fontStyle: string;
  62299. /** Gets or sets font weight */
  62300. fontWeight: string;
  62301. /**
  62302. * Gets or sets style
  62303. * @see http://doc.babylonjs.com/how_to/gui#styles
  62304. */
  62305. style: BABYLON.Nullable<Style>;
  62306. /** @hidden */
  62307. readonly _isFontSizeInPercentage: boolean;
  62308. /** Gets or sets font size in pixels */
  62309. fontSizeInPixels: number;
  62310. /** Gets or sets font size */
  62311. fontSize: string | number;
  62312. /** Gets or sets foreground color */
  62313. color: string;
  62314. /** Gets or sets z index which is used to reorder controls on the z axis */
  62315. zIndex: number;
  62316. /** Gets or sets a boolean indicating if the control can be rendered */
  62317. notRenderable: boolean;
  62318. /** Gets or sets a boolean indicating if the control is visible */
  62319. isVisible: boolean;
  62320. /** Gets a boolean indicating that the control needs to update its rendering */
  62321. readonly isDirty: boolean;
  62322. /**
  62323. * Gets the current linked mesh (or null if none)
  62324. */
  62325. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62326. /**
  62327. * Gets or sets a value indicating the padding to use on the left of the control
  62328. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62329. */
  62330. paddingLeft: string | number;
  62331. /**
  62332. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62333. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62334. */
  62335. paddingLeftInPixels: number;
  62336. /**
  62337. * Gets or sets a value indicating the padding to use on the right of the control
  62338. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62339. */
  62340. paddingRight: string | number;
  62341. /**
  62342. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62343. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62344. */
  62345. paddingRightInPixels: number;
  62346. /**
  62347. * Gets or sets a value indicating the padding to use on the top of the control
  62348. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62349. */
  62350. paddingTop: string | number;
  62351. /**
  62352. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62353. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62354. */
  62355. paddingTopInPixels: number;
  62356. /**
  62357. * Gets or sets a value indicating the padding to use on the bottom of the control
  62358. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62359. */
  62360. paddingBottom: string | number;
  62361. /**
  62362. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62364. */
  62365. paddingBottomInPixels: number;
  62366. /**
  62367. * Gets or sets a value indicating the left coordinate of the control
  62368. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62369. */
  62370. left: string | number;
  62371. /**
  62372. * Gets or sets a value indicating the left coordinate in pixels of the control
  62373. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62374. */
  62375. leftInPixels: number;
  62376. /**
  62377. * Gets or sets a value indicating the top coordinate of the control
  62378. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62379. */
  62380. top: string | number;
  62381. /**
  62382. * Gets or sets a value indicating the top coordinate in pixels of the control
  62383. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62384. */
  62385. topInPixels: number;
  62386. /**
  62387. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62388. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62389. */
  62390. linkOffsetX: string | number;
  62391. /**
  62392. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62393. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62394. */
  62395. linkOffsetXInPixels: number;
  62396. /**
  62397. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62398. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62399. */
  62400. linkOffsetY: string | number;
  62401. /**
  62402. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62403. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62404. */
  62405. linkOffsetYInPixels: number;
  62406. /** Gets the center coordinate on X axis */
  62407. readonly centerX: number;
  62408. /** Gets the center coordinate on Y axis */
  62409. readonly centerY: number;
  62410. /** Gets or sets if control is Enabled*/
  62411. isEnabled: boolean;
  62412. /** Gets or sets background color of control if it's disabled*/
  62413. disabledColor: string;
  62414. /**
  62415. * Creates a new control
  62416. * @param name defines the name of the control
  62417. */
  62418. constructor(
  62419. /** defines the name of the control */
  62420. name?: string | undefined);
  62421. /** @hidden */
  62422. protected _getTypeName(): string;
  62423. /**
  62424. * Gets the first ascendant in the hierarchy of the given type
  62425. * @param className defines the required type
  62426. * @returns the ascendant or null if not found
  62427. */
  62428. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62429. /** @hidden */
  62430. _resetFontCache(): void;
  62431. /**
  62432. * Determines if a container is an ascendant of the current control
  62433. * @param container defines the container to look for
  62434. * @returns true if the container is one of the ascendant of the control
  62435. */
  62436. isAscendant(container: Control): boolean;
  62437. /**
  62438. * Gets coordinates in local control space
  62439. * @param globalCoordinates defines the coordinates to transform
  62440. * @returns the new coordinates in local space
  62441. */
  62442. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62443. /**
  62444. * Gets coordinates in local control space
  62445. * @param globalCoordinates defines the coordinates to transform
  62446. * @param result defines the target vector2 where to store the result
  62447. * @returns the current control
  62448. */
  62449. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62450. /**
  62451. * Gets coordinates in parent local control space
  62452. * @param globalCoordinates defines the coordinates to transform
  62453. * @returns the new coordinates in parent local space
  62454. */
  62455. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62456. /**
  62457. * Move the current control to a vector3 position projected onto the screen.
  62458. * @param position defines the target position
  62459. * @param scene defines the hosting scene
  62460. */
  62461. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62462. /** @hidden */
  62463. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62464. /**
  62465. * Will return all controls that have this control as ascendant
  62466. * @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
  62467. * @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
  62468. * @return all child controls
  62469. */
  62470. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62471. /**
  62472. * Link current control with a target mesh
  62473. * @param mesh defines the mesh to link with
  62474. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62475. */
  62476. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62477. /** @hidden */
  62478. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62479. /** @hidden */
  62480. _offsetLeft(offset: number): void;
  62481. /** @hidden */
  62482. _offsetTop(offset: number): void;
  62483. /** @hidden */
  62484. _markMatrixAsDirty(): void;
  62485. /** @hidden */
  62486. _flagDescendantsAsMatrixDirty(): void;
  62487. /** @hidden */
  62488. _intersectsRect(rect: Measure): boolean;
  62489. /** @hidden */
  62490. protected invalidateRect(): void;
  62491. /** @hidden */
  62492. _markAsDirty(force?: boolean): void;
  62493. /** @hidden */
  62494. _markAllAsDirty(): void;
  62495. /** @hidden */
  62496. _link(host: AdvancedDynamicTexture): void;
  62497. /** @hidden */
  62498. protected _transform(context?: CanvasRenderingContext2D): void;
  62499. /** @hidden */
  62500. _renderHighlight(context: CanvasRenderingContext2D): void;
  62501. /** @hidden */
  62502. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62503. /** @hidden */
  62504. protected _applyStates(context: CanvasRenderingContext2D): void;
  62505. /** @hidden */
  62506. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62507. /** @hidden */
  62508. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62509. protected _evaluateClippingState(parentMeasure: Measure): void;
  62510. /** @hidden */
  62511. _measure(): void;
  62512. /** @hidden */
  62513. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62514. /** @hidden */
  62515. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62516. /** @hidden */
  62517. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62518. /** @hidden */
  62519. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62520. private static _ClipMeasure;
  62521. private _tmpMeasureA;
  62522. private _clip;
  62523. /** @hidden */
  62524. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62525. /** @hidden */
  62526. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62527. /**
  62528. * Tests if a given coordinates belong to the current control
  62529. * @param x defines x coordinate to test
  62530. * @param y defines y coordinate to test
  62531. * @returns true if the coordinates are inside the control
  62532. */
  62533. contains(x: number, y: number): boolean;
  62534. /** @hidden */
  62535. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62536. /** @hidden */
  62537. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62538. /** @hidden */
  62539. _onPointerEnter(target: Control): boolean;
  62540. /** @hidden */
  62541. _onPointerOut(target: Control, force?: boolean): void;
  62542. /** @hidden */
  62543. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62544. /** @hidden */
  62545. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62546. /** @hidden */
  62547. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62548. /** @hidden */
  62549. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62550. private _prepareFont;
  62551. /** Releases associated resources */
  62552. dispose(): void;
  62553. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62554. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62555. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62556. private static _VERTICAL_ALIGNMENT_TOP;
  62557. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62558. private static _VERTICAL_ALIGNMENT_CENTER;
  62559. /** HORIZONTAL_ALIGNMENT_LEFT */
  62560. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62561. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62562. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62563. /** HORIZONTAL_ALIGNMENT_CENTER */
  62564. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62565. /** VERTICAL_ALIGNMENT_TOP */
  62566. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62567. /** VERTICAL_ALIGNMENT_BOTTOM */
  62568. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62569. /** VERTICAL_ALIGNMENT_CENTER */
  62570. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62571. private static _FontHeightSizes;
  62572. /** @hidden */
  62573. static _GetFontOffset(font: string): {
  62574. ascent: number;
  62575. height: number;
  62576. descent: number;
  62577. };
  62578. /**
  62579. * Creates a stack panel that can be used to render headers
  62580. * @param control defines the control to associate with the header
  62581. * @param text defines the text of the header
  62582. * @param size defines the size of the header
  62583. * @param options defines options used to configure the header
  62584. * @returns a new StackPanel
  62585. * @ignore
  62586. * @hidden
  62587. */
  62588. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62589. isHorizontal: boolean;
  62590. controlFirst: boolean;
  62591. }) => any;
  62592. /** @hidden */
  62593. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62594. }
  62595. }
  62596. declare module BABYLON.GUI {
  62597. /**
  62598. * Root class for 2D containers
  62599. * @see http://doc.babylonjs.com/how_to/gui#containers
  62600. */
  62601. export class Container extends Control {
  62602. name?: string | undefined;
  62603. /** @hidden */
  62604. protected _children: Control[];
  62605. /** @hidden */
  62606. protected _measureForChildren: Measure;
  62607. /** @hidden */
  62608. protected _background: string;
  62609. /** @hidden */
  62610. protected _adaptWidthToChildren: boolean;
  62611. /** @hidden */
  62612. protected _adaptHeightToChildren: boolean;
  62613. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62614. adaptHeightToChildren: boolean;
  62615. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62616. adaptWidthToChildren: boolean;
  62617. /** Gets or sets background color */
  62618. background: string;
  62619. /** Gets the list of children */
  62620. readonly children: Control[];
  62621. /**
  62622. * Creates a new Container
  62623. * @param name defines the name of the container
  62624. */
  62625. constructor(name?: string | undefined);
  62626. protected _getTypeName(): string;
  62627. _flagDescendantsAsMatrixDirty(): void;
  62628. /**
  62629. * Gets a child using its name
  62630. * @param name defines the child name to look for
  62631. * @returns the child control if found
  62632. */
  62633. getChildByName(name: string): BABYLON.Nullable<Control>;
  62634. /**
  62635. * Gets a child using its type and its name
  62636. * @param name defines the child name to look for
  62637. * @param type defines the child type to look for
  62638. * @returns the child control if found
  62639. */
  62640. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62641. /**
  62642. * Search for a specific control in children
  62643. * @param control defines the control to look for
  62644. * @returns true if the control is in child list
  62645. */
  62646. containsControl(control: Control): boolean;
  62647. /**
  62648. * Adds a new control to the current container
  62649. * @param control defines the control to add
  62650. * @returns the current container
  62651. */
  62652. addControl(control: BABYLON.Nullable<Control>): Container;
  62653. /**
  62654. * Removes all controls from the current container
  62655. * @returns the current container
  62656. */
  62657. clearControls(): Container;
  62658. /**
  62659. * Removes a control from the current container
  62660. * @param control defines the control to remove
  62661. * @returns the current container
  62662. */
  62663. removeControl(control: Control): Container;
  62664. /** @hidden */
  62665. _reOrderControl(control: Control): void;
  62666. /** @hidden */
  62667. _offsetLeft(offset: number): void;
  62668. /** @hidden */
  62669. _offsetTop(offset: number): void;
  62670. /** @hidden */
  62671. _markAllAsDirty(): void;
  62672. /** @hidden */
  62673. protected _localDraw(context: CanvasRenderingContext2D): void;
  62674. /** @hidden */
  62675. _link(host: AdvancedDynamicTexture): void;
  62676. /** @hidden */
  62677. protected _beforeLayout(): void;
  62678. /** @hidden */
  62679. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62680. /** @hidden */
  62681. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62682. protected _postMeasure(): void;
  62683. /** @hidden */
  62684. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62685. /** @hidden */
  62686. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62687. /** @hidden */
  62688. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62689. /** @hidden */
  62690. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62691. /** Releases associated resources */
  62692. dispose(): void;
  62693. }
  62694. }
  62695. declare module BABYLON.GUI {
  62696. /** Class used to create rectangle container */
  62697. export class Rectangle extends Container {
  62698. name?: string | undefined;
  62699. private _thickness;
  62700. private _cornerRadius;
  62701. /** Gets or sets border thickness */
  62702. thickness: number;
  62703. /** Gets or sets the corner radius angle */
  62704. cornerRadius: number;
  62705. /**
  62706. * Creates a new Rectangle
  62707. * @param name defines the control name
  62708. */
  62709. constructor(name?: string | undefined);
  62710. protected _getTypeName(): string;
  62711. protected _localDraw(context: CanvasRenderingContext2D): void;
  62712. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62713. private _drawRoundedRect;
  62714. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62715. }
  62716. }
  62717. declare module BABYLON.GUI {
  62718. /**
  62719. * Enum that determines the text-wrapping mode to use.
  62720. */
  62721. export enum TextWrapping {
  62722. /**
  62723. * Clip the text when it's larger than Control.width; this is the default mode.
  62724. */
  62725. Clip = 0,
  62726. /**
  62727. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62728. */
  62729. WordWrap = 1,
  62730. /**
  62731. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62732. */
  62733. Ellipsis = 2
  62734. }
  62735. /**
  62736. * Class used to create text block control
  62737. */
  62738. export class TextBlock extends Control {
  62739. /**
  62740. * Defines the name of the control
  62741. */
  62742. name?: string | undefined;
  62743. private _text;
  62744. private _textWrapping;
  62745. private _textHorizontalAlignment;
  62746. private _textVerticalAlignment;
  62747. private _lines;
  62748. private _resizeToFit;
  62749. private _lineSpacing;
  62750. private _outlineWidth;
  62751. private _outlineColor;
  62752. /**
  62753. * An event triggered after the text is changed
  62754. */
  62755. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62756. /**
  62757. * An event triggered after the text was broken up into lines
  62758. */
  62759. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62760. /**
  62761. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62762. */
  62763. readonly lines: any[];
  62764. /**
  62765. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62766. */
  62767. /**
  62768. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62769. */
  62770. resizeToFit: boolean;
  62771. /**
  62772. * Gets or sets a boolean indicating if text must be wrapped
  62773. */
  62774. /**
  62775. * Gets or sets a boolean indicating if text must be wrapped
  62776. */
  62777. textWrapping: TextWrapping | boolean;
  62778. /**
  62779. * Gets or sets text to display
  62780. */
  62781. /**
  62782. * Gets or sets text to display
  62783. */
  62784. text: string;
  62785. /**
  62786. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62787. */
  62788. /**
  62789. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62790. */
  62791. textHorizontalAlignment: number;
  62792. /**
  62793. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62794. */
  62795. /**
  62796. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62797. */
  62798. textVerticalAlignment: number;
  62799. /**
  62800. * Gets or sets line spacing value
  62801. */
  62802. /**
  62803. * Gets or sets line spacing value
  62804. */
  62805. lineSpacing: string | number;
  62806. /**
  62807. * Gets or sets outlineWidth of the text to display
  62808. */
  62809. /**
  62810. * Gets or sets outlineWidth of the text to display
  62811. */
  62812. outlineWidth: number;
  62813. /**
  62814. * Gets or sets outlineColor of the text to display
  62815. */
  62816. /**
  62817. * Gets or sets outlineColor of the text to display
  62818. */
  62819. outlineColor: string;
  62820. /**
  62821. * Creates a new TextBlock object
  62822. * @param name defines the name of the control
  62823. * @param text defines the text to display (emptry string by default)
  62824. */
  62825. constructor(
  62826. /**
  62827. * Defines the name of the control
  62828. */
  62829. name?: string | undefined, text?: string);
  62830. protected _getTypeName(): string;
  62831. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62832. private _drawText;
  62833. /** @hidden */
  62834. _draw(context: CanvasRenderingContext2D): void;
  62835. protected _applyStates(context: CanvasRenderingContext2D): void;
  62836. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  62837. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  62838. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  62839. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  62840. protected _renderLines(context: CanvasRenderingContext2D): void;
  62841. /**
  62842. * Given a width constraint applied on the text block, find the expected height
  62843. * @returns expected height
  62844. */
  62845. computeExpectedHeight(): number;
  62846. dispose(): void;
  62847. }
  62848. }
  62849. declare module BABYLON.GUI {
  62850. /**
  62851. * Class used to create 2D images
  62852. */
  62853. export class Image extends Control {
  62854. name?: string | undefined;
  62855. private static _WorkingCanvas;
  62856. private _domImage;
  62857. private _imageWidth;
  62858. private _imageHeight;
  62859. private _loaded;
  62860. private _stretch;
  62861. private _source;
  62862. private _autoScale;
  62863. private _sourceLeft;
  62864. private _sourceTop;
  62865. private _sourceWidth;
  62866. private _sourceHeight;
  62867. private _cellWidth;
  62868. private _cellHeight;
  62869. private _cellId;
  62870. private _populateNinePatchSlicesFromImage;
  62871. private _sliceLeft;
  62872. private _sliceRight;
  62873. private _sliceTop;
  62874. private _sliceBottom;
  62875. private _detectPointerOnOpaqueOnly;
  62876. /**
  62877. * BABYLON.Observable notified when the content is loaded
  62878. */
  62879. onImageLoadedObservable: BABYLON.Observable<Image>;
  62880. /**
  62881. * Gets a boolean indicating that the content is loaded
  62882. */
  62883. readonly isLoaded: boolean;
  62884. /**
  62885. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  62886. */
  62887. populateNinePatchSlicesFromImage: boolean;
  62888. /**
  62889. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  62890. * Beware using this as this will comsume more memory as the image has to be stored twice
  62891. */
  62892. detectPointerOnOpaqueOnly: boolean;
  62893. /**
  62894. * Gets or sets the left value for slicing (9-patch)
  62895. */
  62896. sliceLeft: number;
  62897. /**
  62898. * Gets or sets the right value for slicing (9-patch)
  62899. */
  62900. sliceRight: number;
  62901. /**
  62902. * Gets or sets the top value for slicing (9-patch)
  62903. */
  62904. sliceTop: number;
  62905. /**
  62906. * Gets or sets the bottom value for slicing (9-patch)
  62907. */
  62908. sliceBottom: number;
  62909. /**
  62910. * Gets or sets the left coordinate in the source image
  62911. */
  62912. sourceLeft: number;
  62913. /**
  62914. * Gets or sets the top coordinate in the source image
  62915. */
  62916. sourceTop: number;
  62917. /**
  62918. * Gets or sets the width to capture in the source image
  62919. */
  62920. sourceWidth: number;
  62921. /**
  62922. * Gets or sets the height to capture in the source image
  62923. */
  62924. sourceHeight: number;
  62925. /**
  62926. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  62927. * @see http://doc.babylonjs.com/how_to/gui#image
  62928. */
  62929. autoScale: boolean;
  62930. /** Gets or sets the streching mode used by the image */
  62931. stretch: number;
  62932. /**
  62933. * Gets or sets the internal DOM image used to render the control
  62934. */
  62935. domImage: HTMLImageElement;
  62936. private _onImageLoaded;
  62937. private _extractNinePatchSliceDataFromImage;
  62938. /**
  62939. * Gets or sets image source url
  62940. */
  62941. source: BABYLON.Nullable<string>;
  62942. /**
  62943. * Gets or sets the cell width to use when animation sheet is enabled
  62944. * @see http://doc.babylonjs.com/how_to/gui#image
  62945. */
  62946. cellWidth: number;
  62947. /**
  62948. * Gets or sets the cell height to use when animation sheet is enabled
  62949. * @see http://doc.babylonjs.com/how_to/gui#image
  62950. */
  62951. cellHeight: number;
  62952. /**
  62953. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  62954. * @see http://doc.babylonjs.com/how_to/gui#image
  62955. */
  62956. cellId: number;
  62957. /**
  62958. * Creates a new Image
  62959. * @param name defines the control name
  62960. * @param url defines the image url
  62961. */
  62962. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  62963. /**
  62964. * Tests if a given coordinates belong to the current control
  62965. * @param x defines x coordinate to test
  62966. * @param y defines y coordinate to test
  62967. * @returns true if the coordinates are inside the control
  62968. */
  62969. contains(x: number, y: number): boolean;
  62970. protected _getTypeName(): string;
  62971. /** Force the control to synchronize with its content */
  62972. synchronizeSizeWithContent(): void;
  62973. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62974. private _prepareWorkingCanvasForOpaqueDetection;
  62975. private _drawImage;
  62976. _draw(context: CanvasRenderingContext2D): void;
  62977. private _renderCornerPatch;
  62978. private _renderNinePatch;
  62979. dispose(): void;
  62980. /** STRETCH_NONE */
  62981. static readonly STRETCH_NONE: number;
  62982. /** STRETCH_FILL */
  62983. static readonly STRETCH_FILL: number;
  62984. /** STRETCH_UNIFORM */
  62985. static readonly STRETCH_UNIFORM: number;
  62986. /** STRETCH_EXTEND */
  62987. static readonly STRETCH_EXTEND: number;
  62988. /** NINE_PATCH */
  62989. static readonly STRETCH_NINE_PATCH: number;
  62990. }
  62991. }
  62992. declare module BABYLON.GUI {
  62993. /**
  62994. * Class used to create 2D buttons
  62995. */
  62996. export class Button extends Rectangle {
  62997. name?: string | undefined;
  62998. /**
  62999. * Function called to generate a pointer enter animation
  63000. */
  63001. pointerEnterAnimation: () => void;
  63002. /**
  63003. * Function called to generate a pointer out animation
  63004. */
  63005. pointerOutAnimation: () => void;
  63006. /**
  63007. * Function called to generate a pointer down animation
  63008. */
  63009. pointerDownAnimation: () => void;
  63010. /**
  63011. * Function called to generate a pointer up animation
  63012. */
  63013. pointerUpAnimation: () => void;
  63014. /**
  63015. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63016. */
  63017. delegatePickingToChildren: boolean;
  63018. private _image;
  63019. /**
  63020. * Returns the image part of the button (if any)
  63021. */
  63022. readonly image: BABYLON.Nullable<Image>;
  63023. private _textBlock;
  63024. /**
  63025. * Returns the image part of the button (if any)
  63026. */
  63027. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63028. /**
  63029. * Creates a new Button
  63030. * @param name defines the name of the button
  63031. */
  63032. constructor(name?: string | undefined);
  63033. protected _getTypeName(): string;
  63034. /** @hidden */
  63035. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63036. /** @hidden */
  63037. _onPointerEnter(target: Control): boolean;
  63038. /** @hidden */
  63039. _onPointerOut(target: Control, force?: boolean): void;
  63040. /** @hidden */
  63041. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63042. /** @hidden */
  63043. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63044. /**
  63045. * Creates a new button made with an image and a text
  63046. * @param name defines the name of the button
  63047. * @param text defines the text of the button
  63048. * @param imageUrl defines the url of the image
  63049. * @returns a new Button
  63050. */
  63051. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63052. /**
  63053. * Creates a new button made with an image
  63054. * @param name defines the name of the button
  63055. * @param imageUrl defines the url of the image
  63056. * @returns a new Button
  63057. */
  63058. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63059. /**
  63060. * Creates a new button made with a text
  63061. * @param name defines the name of the button
  63062. * @param text defines the text of the button
  63063. * @returns a new Button
  63064. */
  63065. static CreateSimpleButton(name: string, text: string): Button;
  63066. /**
  63067. * Creates a new button made with an image and a centered text
  63068. * @param name defines the name of the button
  63069. * @param text defines the text of the button
  63070. * @param imageUrl defines the url of the image
  63071. * @returns a new Button
  63072. */
  63073. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63074. }
  63075. }
  63076. declare module BABYLON.GUI {
  63077. /**
  63078. * Class used to create a 2D stack panel container
  63079. */
  63080. export class StackPanel extends Container {
  63081. name?: string | undefined;
  63082. private _isVertical;
  63083. private _manualWidth;
  63084. private _manualHeight;
  63085. private _doNotTrackManualChanges;
  63086. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63087. isVertical: boolean;
  63088. /**
  63089. * Gets or sets panel width.
  63090. * This value should not be set when in horizontal mode as it will be computed automatically
  63091. */
  63092. width: string | number;
  63093. /**
  63094. * Gets or sets panel height.
  63095. * This value should not be set when in vertical mode as it will be computed automatically
  63096. */
  63097. height: string | number;
  63098. /**
  63099. * Creates a new StackPanel
  63100. * @param name defines control name
  63101. */
  63102. constructor(name?: string | undefined);
  63103. protected _getTypeName(): string;
  63104. /** @hidden */
  63105. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63106. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63107. protected _postMeasure(): void;
  63108. }
  63109. }
  63110. declare module BABYLON.GUI {
  63111. /**
  63112. * Class used to represent a 2D checkbox
  63113. */
  63114. export class Checkbox extends Control {
  63115. name?: string | undefined;
  63116. private _isChecked;
  63117. private _background;
  63118. private _checkSizeRatio;
  63119. private _thickness;
  63120. /** Gets or sets border thickness */
  63121. thickness: number;
  63122. /**
  63123. * BABYLON.Observable raised when isChecked property changes
  63124. */
  63125. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63126. /** Gets or sets a value indicating the ratio between overall size and check size */
  63127. checkSizeRatio: number;
  63128. /** Gets or sets background color */
  63129. background: string;
  63130. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63131. isChecked: boolean;
  63132. /**
  63133. * Creates a new CheckBox
  63134. * @param name defines the control name
  63135. */
  63136. constructor(name?: string | undefined);
  63137. protected _getTypeName(): string;
  63138. /** @hidden */
  63139. _draw(context: CanvasRenderingContext2D): void;
  63140. /** @hidden */
  63141. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63142. /**
  63143. * Utility function to easily create a checkbox with a header
  63144. * @param title defines the label to use for the header
  63145. * @param onValueChanged defines the callback to call when value changes
  63146. * @returns a StackPanel containing the checkbox and a textBlock
  63147. */
  63148. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63149. }
  63150. }
  63151. declare module BABYLON.GUI {
  63152. /**
  63153. * Class used to store key control properties
  63154. */
  63155. export class KeyPropertySet {
  63156. /** Width */
  63157. width?: string;
  63158. /** Height */
  63159. height?: string;
  63160. /** Left padding */
  63161. paddingLeft?: string;
  63162. /** Right padding */
  63163. paddingRight?: string;
  63164. /** Top padding */
  63165. paddingTop?: string;
  63166. /** Bottom padding */
  63167. paddingBottom?: string;
  63168. /** Foreground color */
  63169. color?: string;
  63170. /** Background color */
  63171. background?: string;
  63172. }
  63173. /**
  63174. * Class used to create virtual keyboard
  63175. */
  63176. export class VirtualKeyboard extends StackPanel {
  63177. /** BABYLON.Observable raised when a key is pressed */
  63178. onKeyPressObservable: BABYLON.Observable<string>;
  63179. /** Gets or sets default key button width */
  63180. defaultButtonWidth: string;
  63181. /** Gets or sets default key button height */
  63182. defaultButtonHeight: string;
  63183. /** Gets or sets default key button left padding */
  63184. defaultButtonPaddingLeft: string;
  63185. /** Gets or sets default key button right padding */
  63186. defaultButtonPaddingRight: string;
  63187. /** Gets or sets default key button top padding */
  63188. defaultButtonPaddingTop: string;
  63189. /** Gets or sets default key button bottom padding */
  63190. defaultButtonPaddingBottom: string;
  63191. /** Gets or sets default key button foreground color */
  63192. defaultButtonColor: string;
  63193. /** Gets or sets default key button background color */
  63194. defaultButtonBackground: string;
  63195. /** Gets or sets shift button foreground color */
  63196. shiftButtonColor: string;
  63197. /** Gets or sets shift button thickness*/
  63198. selectedShiftThickness: number;
  63199. /** Gets shift key state */
  63200. shiftState: number;
  63201. protected _getTypeName(): string;
  63202. private _createKey;
  63203. /**
  63204. * Adds a new row of keys
  63205. * @param keys defines the list of keys to add
  63206. * @param propertySets defines the associated property sets
  63207. */
  63208. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63209. /**
  63210. * Set the shift key to a specific state
  63211. * @param shiftState defines the new shift state
  63212. */
  63213. applyShiftState(shiftState: number): void;
  63214. private _currentlyConnectedInputText;
  63215. private _connectedInputTexts;
  63216. private _onKeyPressObserver;
  63217. /** Gets the input text control currently attached to the keyboard */
  63218. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63219. /**
  63220. * Connects the keyboard with an input text control
  63221. *
  63222. * @param input defines the target control
  63223. */
  63224. connect(input: InputText): void;
  63225. /**
  63226. * Disconnects the keyboard from connected InputText controls
  63227. *
  63228. * @param input optionally defines a target control, otherwise all are disconnected
  63229. */
  63230. disconnect(input?: InputText): void;
  63231. private _removeConnectedInputObservables;
  63232. /**
  63233. * Release all resources
  63234. */
  63235. dispose(): void;
  63236. /**
  63237. * Creates a new keyboard using a default layout
  63238. *
  63239. * @param name defines control name
  63240. * @returns a new VirtualKeyboard
  63241. */
  63242. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63243. }
  63244. }
  63245. declare module BABYLON.GUI {
  63246. /**
  63247. * Class used to create input text control
  63248. */
  63249. export class InputText extends Control implements IFocusableControl {
  63250. name?: string | undefined;
  63251. private _text;
  63252. private _placeholderText;
  63253. private _background;
  63254. private _focusedBackground;
  63255. private _focusedColor;
  63256. private _placeholderColor;
  63257. private _thickness;
  63258. private _margin;
  63259. private _autoStretchWidth;
  63260. private _maxWidth;
  63261. private _isFocused;
  63262. private _blinkTimeout;
  63263. private _blinkIsEven;
  63264. private _cursorOffset;
  63265. private _scrollLeft;
  63266. private _textWidth;
  63267. private _clickedCoordinate;
  63268. private _deadKey;
  63269. private _addKey;
  63270. private _currentKey;
  63271. private _isTextHighlightOn;
  63272. private _textHighlightColor;
  63273. private _highligherOpacity;
  63274. private _highlightedText;
  63275. private _startHighlightIndex;
  63276. private _endHighlightIndex;
  63277. private _cursorIndex;
  63278. private _onFocusSelectAll;
  63279. private _isPointerDown;
  63280. private _onClipboardObserver;
  63281. private _onPointerDblTapObserver;
  63282. /** @hidden */
  63283. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63284. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63285. promptMessage: string;
  63286. /** Force disable prompt on mobile device */
  63287. disableMobilePrompt: boolean;
  63288. /** BABYLON.Observable raised when the text changes */
  63289. onTextChangedObservable: BABYLON.Observable<InputText>;
  63290. /** BABYLON.Observable raised just before an entered character is to be added */
  63291. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63292. /** BABYLON.Observable raised when the control gets the focus */
  63293. onFocusObservable: BABYLON.Observable<InputText>;
  63294. /** BABYLON.Observable raised when the control loses the focus */
  63295. onBlurObservable: BABYLON.Observable<InputText>;
  63296. /**Observable raised when the text is highlighted */
  63297. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63298. /**Observable raised when copy event is triggered */
  63299. onTextCopyObservable: BABYLON.Observable<InputText>;
  63300. /** BABYLON.Observable raised when cut event is triggered */
  63301. onTextCutObservable: BABYLON.Observable<InputText>;
  63302. /** BABYLON.Observable raised when paste event is triggered */
  63303. onTextPasteObservable: BABYLON.Observable<InputText>;
  63304. /** BABYLON.Observable raised when a key event was processed */
  63305. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63306. /** Gets or sets the maximum width allowed by the control */
  63307. maxWidth: string | number;
  63308. /** Gets the maximum width allowed by the control in pixels */
  63309. readonly maxWidthInPixels: number;
  63310. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63311. highligherOpacity: number;
  63312. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63313. onFocusSelectAll: boolean;
  63314. /** Gets or sets the text hightlight color */
  63315. textHighlightColor: string;
  63316. /** Gets or sets control margin */
  63317. margin: string;
  63318. /** Gets control margin in pixels */
  63319. readonly marginInPixels: number;
  63320. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63321. autoStretchWidth: boolean;
  63322. /** Gets or sets border thickness */
  63323. thickness: number;
  63324. /** Gets or sets the background color when focused */
  63325. focusedBackground: string;
  63326. /** Gets or sets the background color when focused */
  63327. focusedColor: string;
  63328. /** Gets or sets the background color */
  63329. background: string;
  63330. /** Gets or sets the placeholder color */
  63331. placeholderColor: string;
  63332. /** Gets or sets the text displayed when the control is empty */
  63333. placeholderText: string;
  63334. /** Gets or sets the dead key flag */
  63335. deadKey: boolean;
  63336. /** Gets or sets the highlight text */
  63337. highlightedText: string;
  63338. /** Gets or sets if the current key should be added */
  63339. addKey: boolean;
  63340. /** Gets or sets the value of the current key being entered */
  63341. currentKey: string;
  63342. /** Gets or sets the text displayed in the control */
  63343. text: string;
  63344. /** Gets or sets control width */
  63345. width: string | number;
  63346. /**
  63347. * Creates a new InputText
  63348. * @param name defines the control name
  63349. * @param text defines the text of the control
  63350. */
  63351. constructor(name?: string | undefined, text?: string);
  63352. /** @hidden */
  63353. onBlur(): void;
  63354. /** @hidden */
  63355. onFocus(): void;
  63356. protected _getTypeName(): string;
  63357. /**
  63358. * Function called to get the list of controls that should not steal the focus from this control
  63359. * @returns an array of controls
  63360. */
  63361. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63362. /** @hidden */
  63363. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63364. /** @hidden */
  63365. private _updateValueFromCursorIndex;
  63366. /** @hidden */
  63367. private _processDblClick;
  63368. /** @hidden */
  63369. private _selectAllText;
  63370. /**
  63371. * Handles the keyboard event
  63372. * @param evt Defines the KeyboardEvent
  63373. */
  63374. processKeyboard(evt: KeyboardEvent): void;
  63375. /** @hidden */
  63376. private _onCopyText;
  63377. /** @hidden */
  63378. private _onCutText;
  63379. /** @hidden */
  63380. private _onPasteText;
  63381. _draw(context: CanvasRenderingContext2D): void;
  63382. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63383. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63384. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63385. protected _beforeRenderText(text: string): string;
  63386. dispose(): void;
  63387. }
  63388. }
  63389. declare module BABYLON.GUI {
  63390. /**
  63391. * Class used to create a 2D grid container
  63392. */
  63393. export class Grid extends Container {
  63394. name?: string | undefined;
  63395. private _rowDefinitions;
  63396. private _columnDefinitions;
  63397. private _cells;
  63398. private _childControls;
  63399. /**
  63400. * Gets the number of columns
  63401. */
  63402. readonly columnCount: number;
  63403. /**
  63404. * Gets the number of rows
  63405. */
  63406. readonly rowCount: number;
  63407. /** Gets the list of children */
  63408. readonly children: Control[];
  63409. /** Gets the list of cells (e.g. the containers) */
  63410. readonly cells: {
  63411. [key: string]: Container;
  63412. };
  63413. /**
  63414. * Gets the definition of a specific row
  63415. * @param index defines the index of the row
  63416. * @returns the row definition
  63417. */
  63418. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63419. /**
  63420. * Gets the definition of a specific column
  63421. * @param index defines the index of the column
  63422. * @returns the column definition
  63423. */
  63424. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63425. /**
  63426. * Adds a new row to the grid
  63427. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63428. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63429. * @returns the current grid
  63430. */
  63431. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63432. /**
  63433. * Adds a new column to the grid
  63434. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63435. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63436. * @returns the current grid
  63437. */
  63438. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63439. /**
  63440. * Update a row definition
  63441. * @param index defines the index of the row to update
  63442. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63443. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63444. * @returns the current grid
  63445. */
  63446. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63447. /**
  63448. * Update a column definition
  63449. * @param index defines the index of the column to update
  63450. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63451. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63452. * @returns the current grid
  63453. */
  63454. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63455. /**
  63456. * Gets the list of children stored in a specific cell
  63457. * @param row defines the row to check
  63458. * @param column defines the column to check
  63459. * @returns the list of controls
  63460. */
  63461. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63462. /**
  63463. * Gets a string representing the child cell info (row x column)
  63464. * @param child defines the control to get info from
  63465. * @returns a string containing the child cell info (row x column)
  63466. */
  63467. getChildCellInfo(child: Control): string;
  63468. private _removeCell;
  63469. private _offsetCell;
  63470. /**
  63471. * Remove a column definition at specified index
  63472. * @param index defines the index of the column to remove
  63473. * @returns the current grid
  63474. */
  63475. removeColumnDefinition(index: number): Grid;
  63476. /**
  63477. * Remove a row definition at specified index
  63478. * @param index defines the index of the row to remove
  63479. * @returns the current grid
  63480. */
  63481. removeRowDefinition(index: number): Grid;
  63482. /**
  63483. * Adds a new control to the current grid
  63484. * @param control defines the control to add
  63485. * @param row defines the row where to add the control (0 by default)
  63486. * @param column defines the column where to add the control (0 by default)
  63487. * @returns the current grid
  63488. */
  63489. addControl(control: Control, row?: number, column?: number): Grid;
  63490. /**
  63491. * Removes a control from the current container
  63492. * @param control defines the control to remove
  63493. * @returns the current container
  63494. */
  63495. removeControl(control: Control): Container;
  63496. /**
  63497. * Creates a new Grid
  63498. * @param name defines control name
  63499. */
  63500. constructor(name?: string | undefined);
  63501. protected _getTypeName(): string;
  63502. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63503. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63504. _flagDescendantsAsMatrixDirty(): void;
  63505. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63506. /** Releases associated resources */
  63507. dispose(): void;
  63508. }
  63509. }
  63510. declare module BABYLON.GUI {
  63511. /** Class used to create color pickers */
  63512. export class ColorPicker extends Control {
  63513. name?: string | undefined;
  63514. private static _Epsilon;
  63515. private _colorWheelCanvas;
  63516. private _value;
  63517. private _tmpColor;
  63518. private _pointerStartedOnSquare;
  63519. private _pointerStartedOnWheel;
  63520. private _squareLeft;
  63521. private _squareTop;
  63522. private _squareSize;
  63523. private _h;
  63524. private _s;
  63525. private _v;
  63526. private _lastPointerDownID;
  63527. /**
  63528. * BABYLON.Observable raised when the value changes
  63529. */
  63530. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63531. /** Gets or sets the color of the color picker */
  63532. value: BABYLON.Color3;
  63533. /**
  63534. * Gets or sets control width
  63535. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63536. */
  63537. width: string | number;
  63538. /**
  63539. * Gets or sets control height
  63540. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63541. */
  63542. /** Gets or sets control height */
  63543. height: string | number;
  63544. /** Gets or sets control size */
  63545. size: string | number;
  63546. /**
  63547. * Creates a new ColorPicker
  63548. * @param name defines the control name
  63549. */
  63550. constructor(name?: string | undefined);
  63551. protected _getTypeName(): string;
  63552. /** @hidden */
  63553. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63554. private _updateSquareProps;
  63555. private _drawGradientSquare;
  63556. private _drawCircle;
  63557. private _createColorWheelCanvas;
  63558. /** @hidden */
  63559. _draw(context: CanvasRenderingContext2D): void;
  63560. private _pointerIsDown;
  63561. private _updateValueFromPointer;
  63562. private _isPointOnSquare;
  63563. private _isPointOnWheel;
  63564. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63565. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63566. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63567. /**
  63568. * This function expands the color picker by creating a color picker dialog with manual
  63569. * color value input and the ability to save colors into an array to be used later in
  63570. * subsequent launches of the dialogue.
  63571. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63572. * @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.
  63573. * @returns picked color as a hex string and the saved colors array as hex strings.
  63574. */
  63575. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63576. pickerWidth?: string;
  63577. pickerHeight?: string;
  63578. headerHeight?: string;
  63579. lastColor?: string;
  63580. swatchLimit?: number;
  63581. numSwatchesPerLine?: number;
  63582. savedColors?: Array<string>;
  63583. }): Promise<{
  63584. savedColors?: string[];
  63585. pickedColor: string;
  63586. }>;
  63587. }
  63588. }
  63589. declare module BABYLON.GUI {
  63590. /** Class used to create 2D ellipse containers */
  63591. export class Ellipse extends Container {
  63592. name?: string | undefined;
  63593. private _thickness;
  63594. /** Gets or sets border thickness */
  63595. thickness: number;
  63596. /**
  63597. * Creates a new Ellipse
  63598. * @param name defines the control name
  63599. */
  63600. constructor(name?: string | undefined);
  63601. protected _getTypeName(): string;
  63602. protected _localDraw(context: CanvasRenderingContext2D): void;
  63603. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63604. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63605. }
  63606. }
  63607. declare module BABYLON.GUI {
  63608. /**
  63609. * Class used to create a password control
  63610. */
  63611. export class InputPassword extends InputText {
  63612. protected _beforeRenderText(text: string): string;
  63613. }
  63614. }
  63615. declare module BABYLON.GUI {
  63616. /** Class used to render 2D lines */
  63617. export class Line extends Control {
  63618. name?: string | undefined;
  63619. private _lineWidth;
  63620. private _x1;
  63621. private _y1;
  63622. private _x2;
  63623. private _y2;
  63624. private _dash;
  63625. private _connectedControl;
  63626. private _connectedControlDirtyObserver;
  63627. /** Gets or sets the dash pattern */
  63628. dash: Array<number>;
  63629. /** Gets or sets the control connected with the line end */
  63630. connectedControl: Control;
  63631. /** Gets or sets start coordinates on X axis */
  63632. x1: string | number;
  63633. /** Gets or sets start coordinates on Y axis */
  63634. y1: string | number;
  63635. /** Gets or sets end coordinates on X axis */
  63636. x2: string | number;
  63637. /** Gets or sets end coordinates on Y axis */
  63638. y2: string | number;
  63639. /** Gets or sets line width */
  63640. lineWidth: number;
  63641. /** Gets or sets horizontal alignment */
  63642. horizontalAlignment: number;
  63643. /** Gets or sets vertical alignment */
  63644. verticalAlignment: number;
  63645. private readonly _effectiveX2;
  63646. private readonly _effectiveY2;
  63647. /**
  63648. * Creates a new Line
  63649. * @param name defines the control name
  63650. */
  63651. constructor(name?: string | undefined);
  63652. protected _getTypeName(): string;
  63653. _draw(context: CanvasRenderingContext2D): void;
  63654. _measure(): void;
  63655. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63656. /**
  63657. * Move one end of the line given 3D cartesian coordinates.
  63658. * @param position Targeted world position
  63659. * @param scene BABYLON.Scene
  63660. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63661. */
  63662. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63663. /**
  63664. * Move one end of the line to a position in screen absolute space.
  63665. * @param projectedPosition Position in screen absolute space (X, Y)
  63666. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63667. */
  63668. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63669. }
  63670. }
  63671. declare module BABYLON.GUI {
  63672. /**
  63673. * Class used to store a point for a MultiLine object.
  63674. * The point can be pure 2D coordinates, a mesh or a control
  63675. */
  63676. export class MultiLinePoint {
  63677. private _multiLine;
  63678. private _x;
  63679. private _y;
  63680. private _control;
  63681. private _mesh;
  63682. private _controlObserver;
  63683. private _meshObserver;
  63684. /** @hidden */
  63685. _point: BABYLON.Vector2;
  63686. /**
  63687. * Creates a new MultiLinePoint
  63688. * @param multiLine defines the source MultiLine object
  63689. */
  63690. constructor(multiLine: MultiLine);
  63691. /** Gets or sets x coordinate */
  63692. x: string | number;
  63693. /** Gets or sets y coordinate */
  63694. y: string | number;
  63695. /** Gets or sets the control associated with this point */
  63696. control: BABYLON.Nullable<Control>;
  63697. /** Gets or sets the mesh associated with this point */
  63698. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63699. /** Resets links */
  63700. resetLinks(): void;
  63701. /**
  63702. * Gets a translation vector
  63703. * @returns the translation vector
  63704. */
  63705. translate(): BABYLON.Vector2;
  63706. private _translatePoint;
  63707. /** Release associated resources */
  63708. dispose(): void;
  63709. }
  63710. }
  63711. declare module BABYLON.GUI {
  63712. /**
  63713. * Class used to create multi line control
  63714. */
  63715. export class MultiLine extends Control {
  63716. name?: string | undefined;
  63717. private _lineWidth;
  63718. private _dash;
  63719. private _points;
  63720. private _minX;
  63721. private _minY;
  63722. private _maxX;
  63723. private _maxY;
  63724. /**
  63725. * Creates a new MultiLine
  63726. * @param name defines the control name
  63727. */
  63728. constructor(name?: string | undefined);
  63729. /** Gets or sets dash pattern */
  63730. dash: Array<number>;
  63731. /**
  63732. * Gets point stored at specified index
  63733. * @param index defines the index to look for
  63734. * @returns the requested point if found
  63735. */
  63736. getAt(index: number): MultiLinePoint;
  63737. /** Function called when a point is updated */
  63738. onPointUpdate: () => void;
  63739. /**
  63740. * Adds new points to the point collection
  63741. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63742. * @returns the list of created MultiLinePoint
  63743. */
  63744. add(...items: (AbstractMesh | Control | {
  63745. x: string | number;
  63746. y: string | number;
  63747. })[]): MultiLinePoint[];
  63748. /**
  63749. * Adds a new point to the point collection
  63750. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63751. * @returns the created MultiLinePoint
  63752. */
  63753. push(item?: (AbstractMesh | Control | {
  63754. x: string | number;
  63755. y: string | number;
  63756. })): MultiLinePoint;
  63757. /**
  63758. * Remove a specific value or point from the active point collection
  63759. * @param value defines the value or point to remove
  63760. */
  63761. remove(value: number | MultiLinePoint): void;
  63762. /**
  63763. * Resets this object to initial state (no point)
  63764. */
  63765. reset(): void;
  63766. /**
  63767. * Resets all links
  63768. */
  63769. resetLinks(): void;
  63770. /** Gets or sets line width */
  63771. lineWidth: number;
  63772. horizontalAlignment: number;
  63773. verticalAlignment: number;
  63774. protected _getTypeName(): string;
  63775. _draw(context: CanvasRenderingContext2D): void;
  63776. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63777. _measure(): void;
  63778. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63779. dispose(): void;
  63780. }
  63781. }
  63782. declare module BABYLON.GUI {
  63783. /**
  63784. * Class used to create radio button controls
  63785. */
  63786. export class RadioButton extends Control {
  63787. name?: string | undefined;
  63788. private _isChecked;
  63789. private _background;
  63790. private _checkSizeRatio;
  63791. private _thickness;
  63792. /** Gets or sets border thickness */
  63793. thickness: number;
  63794. /** Gets or sets group name */
  63795. group: string;
  63796. /** BABYLON.Observable raised when isChecked is changed */
  63797. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63798. /** Gets or sets a value indicating the ratio between overall size and check size */
  63799. checkSizeRatio: number;
  63800. /** Gets or sets background color */
  63801. background: string;
  63802. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63803. isChecked: boolean;
  63804. /**
  63805. * Creates a new RadioButton
  63806. * @param name defines the control name
  63807. */
  63808. constructor(name?: string | undefined);
  63809. protected _getTypeName(): string;
  63810. _draw(context: CanvasRenderingContext2D): void;
  63811. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63812. /**
  63813. * Utility function to easily create a radio button with a header
  63814. * @param title defines the label to use for the header
  63815. * @param group defines the group to use for the radio button
  63816. * @param isChecked defines the initial state of the radio button
  63817. * @param onValueChanged defines the callback to call when value changes
  63818. * @returns a StackPanel containing the radio button and a textBlock
  63819. */
  63820. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63821. }
  63822. }
  63823. declare module BABYLON.GUI {
  63824. /**
  63825. * Class used to create slider controls
  63826. */
  63827. export class BaseSlider extends Control {
  63828. name?: string | undefined;
  63829. protected _thumbWidth: ValueAndUnit;
  63830. private _minimum;
  63831. private _maximum;
  63832. private _value;
  63833. private _isVertical;
  63834. protected _barOffset: ValueAndUnit;
  63835. private _isThumbClamped;
  63836. protected _displayThumb: boolean;
  63837. private _step;
  63838. private _lastPointerDownID;
  63839. protected _effectiveBarOffset: number;
  63840. protected _renderLeft: number;
  63841. protected _renderTop: number;
  63842. protected _renderWidth: number;
  63843. protected _renderHeight: number;
  63844. protected _backgroundBoxLength: number;
  63845. protected _backgroundBoxThickness: number;
  63846. protected _effectiveThumbThickness: number;
  63847. /** BABYLON.Observable raised when the sldier value changes */
  63848. onValueChangedObservable: BABYLON.Observable<number>;
  63849. /** Gets or sets a boolean indicating if the thumb must be rendered */
  63850. displayThumb: boolean;
  63851. /** Gets or sets a step to apply to values (0 by default) */
  63852. step: number;
  63853. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  63854. barOffset: string | number;
  63855. /** Gets main bar offset in pixels*/
  63856. readonly barOffsetInPixels: number;
  63857. /** Gets or sets thumb width */
  63858. thumbWidth: string | number;
  63859. /** Gets thumb width in pixels */
  63860. readonly thumbWidthInPixels: number;
  63861. /** Gets or sets minimum value */
  63862. minimum: number;
  63863. /** Gets or sets maximum value */
  63864. maximum: number;
  63865. /** Gets or sets current value */
  63866. value: number;
  63867. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  63868. isVertical: boolean;
  63869. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  63870. isThumbClamped: boolean;
  63871. /**
  63872. * Creates a new BaseSlider
  63873. * @param name defines the control name
  63874. */
  63875. constructor(name?: string | undefined);
  63876. protected _getTypeName(): string;
  63877. protected _getThumbPosition(): number;
  63878. protected _getThumbThickness(type: string): number;
  63879. protected _prepareRenderingData(type: string): void;
  63880. private _pointerIsDown;
  63881. /** @hidden */
  63882. protected _updateValueFromPointer(x: number, y: number): void;
  63883. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63884. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63885. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63886. }
  63887. }
  63888. declare module BABYLON.GUI {
  63889. /**
  63890. * Class used to create slider controls
  63891. */
  63892. export class Slider extends BaseSlider {
  63893. name?: string | undefined;
  63894. private _background;
  63895. private _borderColor;
  63896. private _isThumbCircle;
  63897. protected _displayValueBar: boolean;
  63898. /** Gets or sets a boolean indicating if the value bar must be rendered */
  63899. displayValueBar: boolean;
  63900. /** Gets or sets border color */
  63901. borderColor: string;
  63902. /** Gets or sets background color */
  63903. background: string;
  63904. /** Gets or sets a boolean indicating if the thumb should be round or square */
  63905. isThumbCircle: boolean;
  63906. /**
  63907. * Creates a new Slider
  63908. * @param name defines the control name
  63909. */
  63910. constructor(name?: string | undefined);
  63911. protected _getTypeName(): string;
  63912. _draw(context: CanvasRenderingContext2D): void;
  63913. }
  63914. }
  63915. declare module BABYLON.GUI {
  63916. /** Class used to create a RadioGroup
  63917. * which contains groups of radio buttons
  63918. */
  63919. export class SelectorGroup {
  63920. /** name of SelectorGroup */
  63921. name: string;
  63922. private _groupPanel;
  63923. private _selectors;
  63924. private _groupHeader;
  63925. /**
  63926. * Creates a new SelectorGroup
  63927. * @param name of group, used as a group heading
  63928. */
  63929. constructor(
  63930. /** name of SelectorGroup */
  63931. name: string);
  63932. /** Gets the groupPanel of the SelectorGroup */
  63933. readonly groupPanel: StackPanel;
  63934. /** Gets the selectors array */
  63935. readonly selectors: StackPanel[];
  63936. /** Gets and sets the group header */
  63937. header: string;
  63938. /** @hidden */
  63939. private _addGroupHeader;
  63940. /** @hidden*/
  63941. _getSelector(selectorNb: number): StackPanel | undefined;
  63942. /** Removes the selector at the given position
  63943. * @param selectorNb the position of the selector within the group
  63944. */
  63945. removeSelector(selectorNb: number): void;
  63946. }
  63947. /** Class used to create a CheckboxGroup
  63948. * which contains groups of checkbox buttons
  63949. */
  63950. export class CheckboxGroup extends SelectorGroup {
  63951. /** Adds a checkbox as a control
  63952. * @param text is the label for the selector
  63953. * @param func is the function called when the Selector is checked
  63954. * @param checked is true when Selector is checked
  63955. */
  63956. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  63957. /** @hidden */
  63958. _setSelectorLabel(selectorNb: number, label: string): void;
  63959. /** @hidden */
  63960. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63961. /** @hidden */
  63962. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63963. /** @hidden */
  63964. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63965. }
  63966. /** Class used to create a RadioGroup
  63967. * which contains groups of radio buttons
  63968. */
  63969. export class RadioGroup extends SelectorGroup {
  63970. private _selectNb;
  63971. /** Adds a radio button as a control
  63972. * @param label is the label for the selector
  63973. * @param func is the function called when the Selector is checked
  63974. * @param checked is true when Selector is checked
  63975. */
  63976. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  63977. /** @hidden */
  63978. _setSelectorLabel(selectorNb: number, label: string): void;
  63979. /** @hidden */
  63980. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63981. /** @hidden */
  63982. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63983. /** @hidden */
  63984. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63985. }
  63986. /** Class used to create a SliderGroup
  63987. * which contains groups of slider buttons
  63988. */
  63989. export class SliderGroup extends SelectorGroup {
  63990. /**
  63991. * Adds a slider to the SelectorGroup
  63992. * @param label is the label for the SliderBar
  63993. * @param func is the function called when the Slider moves
  63994. * @param unit is a string describing the units used, eg degrees or metres
  63995. * @param min is the minimum value for the Slider
  63996. * @param max is the maximum value for the Slider
  63997. * @param value is the start value for the Slider between min and max
  63998. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  63999. */
  64000. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64001. /** @hidden */
  64002. _setSelectorLabel(selectorNb: number, label: string): void;
  64003. /** @hidden */
  64004. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64005. /** @hidden */
  64006. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64007. /** @hidden */
  64008. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64009. }
  64010. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64011. * @see http://doc.babylonjs.com/how_to/selector
  64012. */
  64013. export class SelectionPanel extends Rectangle {
  64014. /** name of SelectionPanel */
  64015. name: string;
  64016. /** an array of SelectionGroups */
  64017. groups: SelectorGroup[];
  64018. private _panel;
  64019. private _buttonColor;
  64020. private _buttonBackground;
  64021. private _headerColor;
  64022. private _barColor;
  64023. private _barHeight;
  64024. private _spacerHeight;
  64025. private _labelColor;
  64026. private _groups;
  64027. private _bars;
  64028. /**
  64029. * Creates a new SelectionPanel
  64030. * @param name of SelectionPanel
  64031. * @param groups is an array of SelectionGroups
  64032. */
  64033. constructor(
  64034. /** name of SelectionPanel */
  64035. name: string,
  64036. /** an array of SelectionGroups */
  64037. groups?: SelectorGroup[]);
  64038. protected _getTypeName(): string;
  64039. /** Gets or sets the headerColor */
  64040. headerColor: string;
  64041. private _setHeaderColor;
  64042. /** Gets or sets the button color */
  64043. buttonColor: string;
  64044. private _setbuttonColor;
  64045. /** Gets or sets the label color */
  64046. labelColor: string;
  64047. private _setLabelColor;
  64048. /** Gets or sets the button background */
  64049. buttonBackground: string;
  64050. private _setButtonBackground;
  64051. /** Gets or sets the color of separator bar */
  64052. barColor: string;
  64053. private _setBarColor;
  64054. /** Gets or sets the height of separator bar */
  64055. barHeight: string;
  64056. private _setBarHeight;
  64057. /** Gets or sets the height of spacers*/
  64058. spacerHeight: string;
  64059. private _setSpacerHeight;
  64060. /** Adds a bar between groups */
  64061. private _addSpacer;
  64062. /** Add a group to the selection panel
  64063. * @param group is the selector group to add
  64064. */
  64065. addGroup(group: SelectorGroup): void;
  64066. /** Remove the group from the given position
  64067. * @param groupNb is the position of the group in the list
  64068. */
  64069. removeGroup(groupNb: number): void;
  64070. /** Change a group header label
  64071. * @param label is the new group header label
  64072. * @param groupNb is the number of the group to relabel
  64073. * */
  64074. setHeaderName(label: string, groupNb: number): void;
  64075. /** Change selector label to the one given
  64076. * @param label is the new selector label
  64077. * @param groupNb is the number of the groupcontaining the selector
  64078. * @param selectorNb is the number of the selector within a group to relabel
  64079. * */
  64080. relabel(label: string, groupNb: number, selectorNb: number): void;
  64081. /** For a given group position remove the selector at the given position
  64082. * @param groupNb is the number of the group to remove the selector from
  64083. * @param selectorNb is the number of the selector within the group
  64084. */
  64085. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64086. /** For a given group position of correct type add a checkbox button
  64087. * @param groupNb is the number of the group to remove the selector from
  64088. * @param label is the label for the selector
  64089. * @param func is the function called when the Selector is checked
  64090. * @param checked is true when Selector is checked
  64091. */
  64092. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64093. /** For a given group position of correct type add a radio button
  64094. * @param groupNb is the number of the group to remove the selector from
  64095. * @param label is the label for the selector
  64096. * @param func is the function called when the Selector is checked
  64097. * @param checked is true when Selector is checked
  64098. */
  64099. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64100. /**
  64101. * For a given slider group add a slider
  64102. * @param groupNb is the number of the group to add the slider to
  64103. * @param label is the label for the Slider
  64104. * @param func is the function called when the Slider moves
  64105. * @param unit is a string describing the units used, eg degrees or metres
  64106. * @param min is the minimum value for the Slider
  64107. * @param max is the maximum value for the Slider
  64108. * @param value is the start value for the Slider between min and max
  64109. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64110. */
  64111. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64112. }
  64113. }
  64114. declare module BABYLON.GUI {
  64115. /**
  64116. * Class used to hold a the container for ScrollViewer
  64117. * @hidden
  64118. */
  64119. export class _ScrollViewerWindow extends Container {
  64120. parentClientWidth: number;
  64121. parentClientHeight: number;
  64122. /**
  64123. * Creates a new ScrollViewerWindow
  64124. * @param name of ScrollViewerWindow
  64125. */
  64126. constructor(name?: string);
  64127. protected _getTypeName(): string;
  64128. /** @hidden */
  64129. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64130. protected _postMeasure(): void;
  64131. }
  64132. }
  64133. declare module BABYLON.GUI {
  64134. /**
  64135. * Class used to create slider controls
  64136. */
  64137. export class ScrollBar extends BaseSlider {
  64138. name?: string | undefined;
  64139. private _background;
  64140. private _borderColor;
  64141. private _thumbMeasure;
  64142. /** Gets or sets border color */
  64143. borderColor: string;
  64144. /** Gets or sets background color */
  64145. background: string;
  64146. /**
  64147. * Creates a new Slider
  64148. * @param name defines the control name
  64149. */
  64150. constructor(name?: string | undefined);
  64151. protected _getTypeName(): string;
  64152. protected _getThumbThickness(): number;
  64153. _draw(context: CanvasRenderingContext2D): void;
  64154. private _first;
  64155. private _originX;
  64156. private _originY;
  64157. /** @hidden */
  64158. protected _updateValueFromPointer(x: number, y: number): void;
  64159. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64160. }
  64161. }
  64162. declare module BABYLON.GUI {
  64163. /**
  64164. * Class used to hold a viewer window and sliders in a grid
  64165. */
  64166. export class ScrollViewer extends Rectangle {
  64167. private _grid;
  64168. private _horizontalBarSpace;
  64169. private _verticalBarSpace;
  64170. private _dragSpace;
  64171. private _horizontalBar;
  64172. private _verticalBar;
  64173. private _barColor;
  64174. private _barBackground;
  64175. private _barSize;
  64176. private _endLeft;
  64177. private _endTop;
  64178. private _window;
  64179. private _pointerIsOver;
  64180. private _wheelPrecision;
  64181. private _onPointerObserver;
  64182. private _clientWidth;
  64183. private _clientHeight;
  64184. /**
  64185. * Gets the horizontal scrollbar
  64186. */
  64187. readonly horizontalBar: ScrollBar;
  64188. /**
  64189. * Gets the vertical scrollbar
  64190. */
  64191. readonly verticalBar: ScrollBar;
  64192. /**
  64193. * Adds a new control to the current container
  64194. * @param control defines the control to add
  64195. * @returns the current container
  64196. */
  64197. addControl(control: BABYLON.Nullable<Control>): Container;
  64198. /**
  64199. * Removes a control from the current container
  64200. * @param control defines the control to remove
  64201. * @returns the current container
  64202. */
  64203. removeControl(control: Control): Container;
  64204. /** Gets the list of children */
  64205. readonly children: Control[];
  64206. _flagDescendantsAsMatrixDirty(): void;
  64207. /**
  64208. * Creates a new ScrollViewer
  64209. * @param name of ScrollViewer
  64210. */
  64211. constructor(name?: string);
  64212. /** Reset the scroll viewer window to initial size */
  64213. resetWindow(): void;
  64214. protected _getTypeName(): string;
  64215. private _buildClientSizes;
  64216. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64217. protected _postMeasure(): void;
  64218. /**
  64219. * Gets or sets the mouse wheel precision
  64220. * from 0 to 1 with a default value of 0.05
  64221. * */
  64222. wheelPrecision: number;
  64223. /** Gets or sets the bar color */
  64224. barColor: string;
  64225. /** Gets or sets the size of the bar */
  64226. barSize: number;
  64227. /** Gets or sets the bar background */
  64228. barBackground: string;
  64229. /** @hidden */
  64230. private _updateScroller;
  64231. _link(host: AdvancedDynamicTexture): void;
  64232. /** @hidden */
  64233. private _attachWheel;
  64234. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64235. /** Releases associated resources */
  64236. dispose(): void;
  64237. }
  64238. }
  64239. declare module BABYLON.GUI {
  64240. /** Class used to render a grid */
  64241. export class DisplayGrid extends Control {
  64242. name?: string | undefined;
  64243. private _cellWidth;
  64244. private _cellHeight;
  64245. private _minorLineTickness;
  64246. private _minorLineColor;
  64247. private _majorLineTickness;
  64248. private _majorLineColor;
  64249. private _majorLineFrequency;
  64250. private _background;
  64251. private _displayMajorLines;
  64252. private _displayMinorLines;
  64253. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64254. displayMinorLines: boolean;
  64255. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64256. displayMajorLines: boolean;
  64257. /** Gets or sets background color (Black by default) */
  64258. background: string;
  64259. /** Gets or sets the width of each cell (20 by default) */
  64260. cellWidth: number;
  64261. /** Gets or sets the height of each cell (20 by default) */
  64262. cellHeight: number;
  64263. /** Gets or sets the tickness of minor lines (1 by default) */
  64264. minorLineTickness: number;
  64265. /** Gets or sets the color of minor lines (DarkGray by default) */
  64266. minorLineColor: string;
  64267. /** Gets or sets the tickness of major lines (2 by default) */
  64268. majorLineTickness: number;
  64269. /** Gets or sets the color of major lines (White by default) */
  64270. majorLineColor: string;
  64271. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64272. majorLineFrequency: number;
  64273. /**
  64274. * Creates a new GridDisplayRectangle
  64275. * @param name defines the control name
  64276. */
  64277. constructor(name?: string | undefined);
  64278. _draw(context: CanvasRenderingContext2D): void;
  64279. protected _getTypeName(): string;
  64280. }
  64281. }
  64282. declare module BABYLON.GUI {
  64283. /**
  64284. * Class used to create slider controls based on images
  64285. */
  64286. export class ImageBasedSlider extends BaseSlider {
  64287. name?: string | undefined;
  64288. private _backgroundImage;
  64289. private _thumbImage;
  64290. private _valueBarImage;
  64291. private _tempMeasure;
  64292. displayThumb: boolean;
  64293. /**
  64294. * Gets or sets the image used to render the background
  64295. */
  64296. backgroundImage: Image;
  64297. /**
  64298. * Gets or sets the image used to render the value bar
  64299. */
  64300. valueBarImage: Image;
  64301. /**
  64302. * Gets or sets the image used to render the thumb
  64303. */
  64304. thumbImage: Image;
  64305. /**
  64306. * Creates a new ImageBasedSlider
  64307. * @param name defines the control name
  64308. */
  64309. constructor(name?: string | undefined);
  64310. protected _getTypeName(): string;
  64311. _draw(context: CanvasRenderingContext2D): void;
  64312. }
  64313. }
  64314. declare module BABYLON.GUI {
  64315. /**
  64316. * Forcing an export so that this code will execute
  64317. * @hidden
  64318. */
  64319. const name = "Statics";
  64320. }
  64321. declare module BABYLON.GUI {
  64322. /**
  64323. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64324. */
  64325. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64326. /**
  64327. * Define the instrumented AdvancedDynamicTexture.
  64328. */
  64329. texture: AdvancedDynamicTexture;
  64330. private _captureRenderTime;
  64331. private _renderTime;
  64332. private _captureLayoutTime;
  64333. private _layoutTime;
  64334. private _onBeginRenderObserver;
  64335. private _onEndRenderObserver;
  64336. private _onBeginLayoutObserver;
  64337. private _onEndLayoutObserver;
  64338. /**
  64339. * Gets the perf counter used to capture render time
  64340. */
  64341. readonly renderTimeCounter: BABYLON.PerfCounter;
  64342. /**
  64343. * Gets the perf counter used to capture layout time
  64344. */
  64345. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64346. /**
  64347. * Enable or disable the render time capture
  64348. */
  64349. captureRenderTime: boolean;
  64350. /**
  64351. * Enable or disable the layout time capture
  64352. */
  64353. captureLayoutTime: boolean;
  64354. /**
  64355. * Instantiates a new advanced dynamic texture instrumentation.
  64356. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64357. * @param texture Defines the AdvancedDynamicTexture to instrument
  64358. */
  64359. constructor(
  64360. /**
  64361. * Define the instrumented AdvancedDynamicTexture.
  64362. */
  64363. texture: AdvancedDynamicTexture);
  64364. /**
  64365. * Dispose and release associated resources.
  64366. */
  64367. dispose(): void;
  64368. }
  64369. }
  64370. declare module BABYLON.GUI {
  64371. /**
  64372. * Class used to create containers for controls
  64373. */
  64374. export class Container3D extends Control3D {
  64375. private _blockLayout;
  64376. /**
  64377. * Gets the list of child controls
  64378. */
  64379. protected _children: Control3D[];
  64380. /**
  64381. * Gets the list of child controls
  64382. */
  64383. readonly children: Array<Control3D>;
  64384. /**
  64385. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64386. * This is helpful to optimize layout operation when adding multiple children in a row
  64387. */
  64388. blockLayout: boolean;
  64389. /**
  64390. * Creates a new container
  64391. * @param name defines the container name
  64392. */
  64393. constructor(name?: string);
  64394. /**
  64395. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64396. * @returns the current container
  64397. */
  64398. updateLayout(): Container3D;
  64399. /**
  64400. * Gets a boolean indicating if the given control is in the children of this control
  64401. * @param control defines the control to check
  64402. * @returns true if the control is in the child list
  64403. */
  64404. containsControl(control: Control3D): boolean;
  64405. /**
  64406. * Adds a control to the children of this control
  64407. * @param control defines the control to add
  64408. * @returns the current container
  64409. */
  64410. addControl(control: Control3D): Container3D;
  64411. /**
  64412. * This function will be called everytime a new control is added
  64413. */
  64414. protected _arrangeChildren(): void;
  64415. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64416. /**
  64417. * Removes a control from the children of this control
  64418. * @param control defines the control to remove
  64419. * @returns the current container
  64420. */
  64421. removeControl(control: Control3D): Container3D;
  64422. protected _getTypeName(): string;
  64423. /**
  64424. * Releases all associated resources
  64425. */
  64426. dispose(): void;
  64427. /** Control rotation will remain unchanged */
  64428. static readonly UNSET_ORIENTATION: number;
  64429. /** Control will rotate to make it look at sphere central axis */
  64430. static readonly FACEORIGIN_ORIENTATION: number;
  64431. /** Control will rotate to make it look back at sphere central axis */
  64432. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64433. /** Control will rotate to look at z axis (0, 0, 1) */
  64434. static readonly FACEFORWARD_ORIENTATION: number;
  64435. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64436. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64437. }
  64438. }
  64439. declare module BABYLON.GUI {
  64440. /**
  64441. * Class used to manage 3D user interface
  64442. * @see http://doc.babylonjs.com/how_to/gui3d
  64443. */
  64444. export class GUI3DManager implements BABYLON.IDisposable {
  64445. private _scene;
  64446. private _sceneDisposeObserver;
  64447. private _utilityLayer;
  64448. private _rootContainer;
  64449. private _pointerObserver;
  64450. private _pointerOutObserver;
  64451. /** @hidden */
  64452. _lastPickedControl: Control3D;
  64453. /** @hidden */
  64454. _lastControlOver: {
  64455. [pointerId: number]: Control3D;
  64456. };
  64457. /** @hidden */
  64458. _lastControlDown: {
  64459. [pointerId: number]: Control3D;
  64460. };
  64461. /**
  64462. * BABYLON.Observable raised when the point picked by the pointer events changed
  64463. */
  64464. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64465. /** @hidden */
  64466. _sharedMaterials: {
  64467. [key: string]: BABYLON.Material;
  64468. };
  64469. /** Gets the hosting scene */
  64470. readonly scene: BABYLON.Scene;
  64471. /** Gets associated utility layer */
  64472. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64473. /**
  64474. * Creates a new GUI3DManager
  64475. * @param scene
  64476. */
  64477. constructor(scene?: BABYLON.Scene);
  64478. private _handlePointerOut;
  64479. private _doPicking;
  64480. /**
  64481. * Gets the root container
  64482. */
  64483. readonly rootContainer: Container3D;
  64484. /**
  64485. * Gets a boolean indicating if the given control is in the root child list
  64486. * @param control defines the control to check
  64487. * @returns true if the control is in the root child list
  64488. */
  64489. containsControl(control: Control3D): boolean;
  64490. /**
  64491. * Adds a control to the root child list
  64492. * @param control defines the control to add
  64493. * @returns the current manager
  64494. */
  64495. addControl(control: Control3D): GUI3DManager;
  64496. /**
  64497. * Removes a control from the root child list
  64498. * @param control defines the control to remove
  64499. * @returns the current container
  64500. */
  64501. removeControl(control: Control3D): GUI3DManager;
  64502. /**
  64503. * Releases all associated resources
  64504. */
  64505. dispose(): void;
  64506. }
  64507. }
  64508. declare module BABYLON.GUI {
  64509. /**
  64510. * Class used to transport BABYLON.Vector3 information for pointer events
  64511. */
  64512. export class Vector3WithInfo extends BABYLON.Vector3 {
  64513. /** defines the current mouse button index */
  64514. buttonIndex: number;
  64515. /**
  64516. * Creates a new Vector3WithInfo
  64517. * @param source defines the vector3 data to transport
  64518. * @param buttonIndex defines the current mouse button index
  64519. */
  64520. constructor(source: BABYLON.Vector3,
  64521. /** defines the current mouse button index */
  64522. buttonIndex?: number);
  64523. }
  64524. }
  64525. declare module BABYLON.GUI {
  64526. /**
  64527. * Class used as base class for controls
  64528. */
  64529. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64530. /** Defines the control name */
  64531. name?: string | undefined;
  64532. /** @hidden */
  64533. _host: GUI3DManager;
  64534. private _node;
  64535. private _downCount;
  64536. private _enterCount;
  64537. private _downPointerIds;
  64538. private _isVisible;
  64539. /** Gets or sets the control position in world space */
  64540. position: BABYLON.Vector3;
  64541. /** Gets or sets the control scaling in world space */
  64542. scaling: BABYLON.Vector3;
  64543. /** Callback used to start pointer enter animation */
  64544. pointerEnterAnimation: () => void;
  64545. /** Callback used to start pointer out animation */
  64546. pointerOutAnimation: () => void;
  64547. /** Callback used to start pointer down animation */
  64548. pointerDownAnimation: () => void;
  64549. /** Callback used to start pointer up animation */
  64550. pointerUpAnimation: () => void;
  64551. /**
  64552. * An event triggered when the pointer move over the control
  64553. */
  64554. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64555. /**
  64556. * An event triggered when the pointer move out of the control
  64557. */
  64558. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64559. /**
  64560. * An event triggered when the pointer taps the control
  64561. */
  64562. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64563. /**
  64564. * An event triggered when pointer is up
  64565. */
  64566. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64567. /**
  64568. * An event triggered when a control is clicked on (with a mouse)
  64569. */
  64570. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64571. /**
  64572. * An event triggered when pointer enters the control
  64573. */
  64574. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64575. /**
  64576. * Gets or sets the parent container
  64577. */
  64578. parent: BABYLON.Nullable<Container3D>;
  64579. private _behaviors;
  64580. /**
  64581. * Gets the list of attached behaviors
  64582. * @see http://doc.babylonjs.com/features/behaviour
  64583. */
  64584. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64585. /**
  64586. * Attach a behavior to the control
  64587. * @see http://doc.babylonjs.com/features/behaviour
  64588. * @param behavior defines the behavior to attach
  64589. * @returns the current control
  64590. */
  64591. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64592. /**
  64593. * Remove an attached behavior
  64594. * @see http://doc.babylonjs.com/features/behaviour
  64595. * @param behavior defines the behavior to attach
  64596. * @returns the current control
  64597. */
  64598. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64599. /**
  64600. * Gets an attached behavior by name
  64601. * @param name defines the name of the behavior to look for
  64602. * @see http://doc.babylonjs.com/features/behaviour
  64603. * @returns null if behavior was not found else the requested behavior
  64604. */
  64605. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64606. /** Gets or sets a boolean indicating if the control is visible */
  64607. isVisible: boolean;
  64608. /**
  64609. * Creates a new control
  64610. * @param name defines the control name
  64611. */
  64612. constructor(
  64613. /** Defines the control name */
  64614. name?: string | undefined);
  64615. /**
  64616. * Gets a string representing the class name
  64617. */
  64618. readonly typeName: string;
  64619. /**
  64620. * Get the current class name of the control.
  64621. * @returns current class name
  64622. */
  64623. getClassName(): string;
  64624. protected _getTypeName(): string;
  64625. /**
  64626. * Gets the transform node used by this control
  64627. */
  64628. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64629. /**
  64630. * Gets the mesh used to render this control
  64631. */
  64632. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64633. /**
  64634. * Link the control as child of the given node
  64635. * @param node defines the node to link to. Use null to unlink the control
  64636. * @returns the current control
  64637. */
  64638. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64639. /** @hidden **/
  64640. _prepareNode(scene: BABYLON.Scene): void;
  64641. /**
  64642. * Node creation.
  64643. * Can be overriden by children
  64644. * @param scene defines the scene where the node must be attached
  64645. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64646. */
  64647. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64648. /**
  64649. * Affect a material to the given mesh
  64650. * @param mesh defines the mesh which will represent the control
  64651. */
  64652. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64653. /** @hidden */
  64654. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64655. /** @hidden */
  64656. _onPointerEnter(target: Control3D): boolean;
  64657. /** @hidden */
  64658. _onPointerOut(target: Control3D): void;
  64659. /** @hidden */
  64660. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64661. /** @hidden */
  64662. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64663. /** @hidden */
  64664. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64665. /** @hidden */
  64666. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64667. /** @hidden */
  64668. _disposeNode(): void;
  64669. /**
  64670. * Releases all associated resources
  64671. */
  64672. dispose(): void;
  64673. }
  64674. }
  64675. declare module BABYLON.GUI {
  64676. /**
  64677. * Class used as a root to all buttons
  64678. */
  64679. export class AbstractButton3D extends Control3D {
  64680. /**
  64681. * Creates a new button
  64682. * @param name defines the control name
  64683. */
  64684. constructor(name?: string);
  64685. protected _getTypeName(): string;
  64686. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64687. }
  64688. }
  64689. declare module BABYLON.GUI {
  64690. /**
  64691. * Class used to create a button in 3D
  64692. */
  64693. export class Button3D extends AbstractButton3D {
  64694. /** @hidden */
  64695. protected _currentMaterial: BABYLON.Material;
  64696. private _facadeTexture;
  64697. private _content;
  64698. private _contentResolution;
  64699. private _contentScaleRatio;
  64700. /**
  64701. * Gets or sets the texture resolution used to render content (512 by default)
  64702. */
  64703. contentResolution: BABYLON.int;
  64704. /**
  64705. * Gets or sets the texture scale ratio used to render content (2 by default)
  64706. */
  64707. contentScaleRatio: number;
  64708. protected _disposeFacadeTexture(): void;
  64709. protected _resetContent(): void;
  64710. /**
  64711. * Creates a new button
  64712. * @param name defines the control name
  64713. */
  64714. constructor(name?: string);
  64715. /**
  64716. * Gets or sets the GUI 2D content used to display the button's facade
  64717. */
  64718. content: Control;
  64719. /**
  64720. * Apply the facade texture (created from the content property).
  64721. * This function can be overloaded by child classes
  64722. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64723. */
  64724. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64725. protected _getTypeName(): string;
  64726. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64727. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64728. /**
  64729. * Releases all associated resources
  64730. */
  64731. dispose(): void;
  64732. }
  64733. }
  64734. declare module BABYLON.GUI {
  64735. /**
  64736. * Abstract class used to create a container panel deployed on the surface of a volume
  64737. */
  64738. export abstract class VolumeBasedPanel extends Container3D {
  64739. private _columns;
  64740. private _rows;
  64741. private _rowThenColum;
  64742. private _orientation;
  64743. protected _cellWidth: number;
  64744. protected _cellHeight: number;
  64745. /**
  64746. * Gets or sets the distance between elements
  64747. */
  64748. margin: number;
  64749. /**
  64750. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64751. * | Value | Type | Description |
  64752. * | ----- | ----------------------------------- | ----------- |
  64753. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64754. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64755. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64756. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64757. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64758. */
  64759. orientation: number;
  64760. /**
  64761. * Gets or sets the number of columns requested (10 by default).
  64762. * The panel will automatically compute the number of rows based on number of child controls.
  64763. */
  64764. columns: BABYLON.int;
  64765. /**
  64766. * Gets or sets a the number of rows requested.
  64767. * The panel will automatically compute the number of columns based on number of child controls.
  64768. */
  64769. rows: BABYLON.int;
  64770. /**
  64771. * Creates new VolumeBasedPanel
  64772. */
  64773. constructor();
  64774. protected _arrangeChildren(): void;
  64775. /** Child classes must implement this function to provide correct control positioning */
  64776. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64777. /** Child classes can implement this function to provide additional processing */
  64778. protected _finalProcessing(): void;
  64779. }
  64780. }
  64781. declare module BABYLON.GUI {
  64782. /**
  64783. * Class used to create a container panel deployed on the surface of a cylinder
  64784. */
  64785. export class CylinderPanel extends VolumeBasedPanel {
  64786. private _radius;
  64787. /**
  64788. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64789. */
  64790. radius: BABYLON.float;
  64791. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64792. private _cylindricalMapping;
  64793. }
  64794. }
  64795. declare module BABYLON.GUI {
  64796. /** @hidden */
  64797. export var fluentVertexShader: {
  64798. name: string;
  64799. shader: string;
  64800. };
  64801. }
  64802. declare module BABYLON.GUI {
  64803. /** @hidden */
  64804. export var fluentPixelShader: {
  64805. name: string;
  64806. shader: string;
  64807. };
  64808. }
  64809. declare module BABYLON.GUI {
  64810. /** @hidden */
  64811. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64812. INNERGLOW: boolean;
  64813. BORDER: boolean;
  64814. HOVERLIGHT: boolean;
  64815. TEXTURE: boolean;
  64816. constructor();
  64817. }
  64818. /**
  64819. * Class used to render controls with fluent desgin
  64820. */
  64821. export class FluentMaterial extends BABYLON.PushMaterial {
  64822. /**
  64823. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64824. */
  64825. innerGlowColorIntensity: number;
  64826. /**
  64827. * Gets or sets the inner glow color (white by default)
  64828. */
  64829. innerGlowColor: BABYLON.Color3;
  64830. /**
  64831. * Gets or sets alpha value (default is 1.0)
  64832. */
  64833. alpha: number;
  64834. /**
  64835. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64836. */
  64837. albedoColor: BABYLON.Color3;
  64838. /**
  64839. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64840. */
  64841. renderBorders: boolean;
  64842. /**
  64843. * Gets or sets border width (default is 0.5)
  64844. */
  64845. borderWidth: number;
  64846. /**
  64847. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64848. */
  64849. edgeSmoothingValue: number;
  64850. /**
  64851. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64852. */
  64853. borderMinValue: number;
  64854. /**
  64855. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64856. */
  64857. renderHoverLight: boolean;
  64858. /**
  64859. * Gets or sets the radius used to render the hover light (default is 1.0)
  64860. */
  64861. hoverRadius: number;
  64862. /**
  64863. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64864. */
  64865. hoverColor: BABYLON.Color4;
  64866. /**
  64867. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  64868. */
  64869. hoverPosition: BABYLON.Vector3;
  64870. private _albedoTexture;
  64871. /** Gets or sets the texture to use for albedo color */
  64872. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  64873. /**
  64874. * Creates a new Fluent material
  64875. * @param name defines the name of the material
  64876. * @param scene defines the hosting scene
  64877. */
  64878. constructor(name: string, scene: BABYLON.Scene);
  64879. needAlphaBlending(): boolean;
  64880. needAlphaTesting(): boolean;
  64881. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64882. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64883. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64884. getActiveTextures(): BABYLON.BaseTexture[];
  64885. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64886. dispose(forceDisposeEffect?: boolean): void;
  64887. clone(name: string): FluentMaterial;
  64888. serialize(): any;
  64889. getClassName(): string;
  64890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  64891. }
  64892. }
  64893. declare module BABYLON.GUI {
  64894. /**
  64895. * Class used to create a holographic button in 3D
  64896. */
  64897. export class HolographicButton extends Button3D {
  64898. private _backPlate;
  64899. private _textPlate;
  64900. private _frontPlate;
  64901. private _text;
  64902. private _imageUrl;
  64903. private _shareMaterials;
  64904. private _frontMaterial;
  64905. private _backMaterial;
  64906. private _plateMaterial;
  64907. private _pickedPointObserver;
  64908. private _tooltipFade;
  64909. private _tooltipTextBlock;
  64910. private _tooltipTexture;
  64911. private _tooltipMesh;
  64912. private _tooltipHoverObserver;
  64913. private _tooltipOutObserver;
  64914. private _disposeTooltip;
  64915. /**
  64916. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  64917. */
  64918. tooltipText: BABYLON.Nullable<string>;
  64919. /**
  64920. * Gets or sets text for the button
  64921. */
  64922. text: string;
  64923. /**
  64924. * Gets or sets the image url for the button
  64925. */
  64926. imageUrl: string;
  64927. /**
  64928. * Gets the back material used by this button
  64929. */
  64930. readonly backMaterial: FluentMaterial;
  64931. /**
  64932. * Gets the front material used by this button
  64933. */
  64934. readonly frontMaterial: FluentMaterial;
  64935. /**
  64936. * Gets the plate material used by this button
  64937. */
  64938. readonly plateMaterial: BABYLON.StandardMaterial;
  64939. /**
  64940. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  64941. */
  64942. readonly shareMaterials: boolean;
  64943. /**
  64944. * Creates a new button
  64945. * @param name defines the control name
  64946. */
  64947. constructor(name?: string, shareMaterials?: boolean);
  64948. protected _getTypeName(): string;
  64949. private _rebuildContent;
  64950. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64951. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64952. private _createBackMaterial;
  64953. private _createFrontMaterial;
  64954. private _createPlateMaterial;
  64955. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  64956. /**
  64957. * Releases all associated resources
  64958. */
  64959. dispose(): void;
  64960. }
  64961. }
  64962. declare module BABYLON.GUI {
  64963. /**
  64964. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  64965. */
  64966. export class MeshButton3D extends Button3D {
  64967. /** @hidden */
  64968. protected _currentMesh: BABYLON.Mesh;
  64969. /**
  64970. * Creates a new 3D button based on a mesh
  64971. * @param mesh mesh to become a 3D button
  64972. * @param name defines the control name
  64973. */
  64974. constructor(mesh: BABYLON.Mesh, name?: string);
  64975. protected _getTypeName(): string;
  64976. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64977. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64978. }
  64979. }
  64980. declare module BABYLON.GUI {
  64981. /**
  64982. * Class used to create a container panel deployed on the surface of a plane
  64983. */
  64984. export class PlanePanel extends VolumeBasedPanel {
  64985. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64986. }
  64987. }
  64988. declare module BABYLON.GUI {
  64989. /**
  64990. * Class used to create a container panel where items get randomized planar mapping
  64991. */
  64992. export class ScatterPanel extends VolumeBasedPanel {
  64993. private _iteration;
  64994. /**
  64995. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  64996. */
  64997. iteration: BABYLON.float;
  64998. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64999. private _scatterMapping;
  65000. protected _finalProcessing(): void;
  65001. }
  65002. }
  65003. declare module BABYLON.GUI {
  65004. /**
  65005. * Class used to create a container panel deployed on the surface of a sphere
  65006. */
  65007. export class SpherePanel extends VolumeBasedPanel {
  65008. private _radius;
  65009. /**
  65010. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65011. */
  65012. radius: BABYLON.float;
  65013. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65014. private _sphericalMapping;
  65015. }
  65016. }
  65017. declare module BABYLON.GUI {
  65018. /**
  65019. * Class used to create a stack panel in 3D on XY plane
  65020. */
  65021. export class StackPanel3D extends Container3D {
  65022. private _isVertical;
  65023. /**
  65024. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65025. */
  65026. isVertical: boolean;
  65027. /**
  65028. * Gets or sets the distance between elements
  65029. */
  65030. margin: number;
  65031. /**
  65032. * Creates new StackPanel
  65033. * @param isVertical
  65034. */
  65035. constructor(isVertical?: boolean);
  65036. protected _arrangeChildren(): void;
  65037. }
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * Mode that determines the coordinate system to use.
  65042. */
  65043. export enum GLTFLoaderCoordinateSystemMode {
  65044. /**
  65045. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65046. */
  65047. AUTO = 0,
  65048. /**
  65049. * Sets the useRightHandedSystem flag on the scene.
  65050. */
  65051. FORCE_RIGHT_HANDED = 1
  65052. }
  65053. /**
  65054. * Mode that determines what animations will start.
  65055. */
  65056. export enum GLTFLoaderAnimationStartMode {
  65057. /**
  65058. * No animation will start.
  65059. */
  65060. NONE = 0,
  65061. /**
  65062. * The first animation will start.
  65063. */
  65064. FIRST = 1,
  65065. /**
  65066. * All animations will start.
  65067. */
  65068. ALL = 2
  65069. }
  65070. /**
  65071. * Interface that contains the data for the glTF asset.
  65072. */
  65073. export interface IGLTFLoaderData {
  65074. /**
  65075. * Object that represents the glTF JSON.
  65076. */
  65077. json: Object;
  65078. /**
  65079. * The BIN chunk of a binary glTF.
  65080. */
  65081. bin: Nullable<ArrayBufferView>;
  65082. }
  65083. /**
  65084. * Interface for extending the loader.
  65085. */
  65086. export interface IGLTFLoaderExtension {
  65087. /**
  65088. * The name of this extension.
  65089. */
  65090. readonly name: string;
  65091. /**
  65092. * Defines whether this extension is enabled.
  65093. */
  65094. enabled: boolean;
  65095. }
  65096. /**
  65097. * Loader state.
  65098. */
  65099. export enum GLTFLoaderState {
  65100. /**
  65101. * The asset is loading.
  65102. */
  65103. LOADING = 0,
  65104. /**
  65105. * The asset is ready for rendering.
  65106. */
  65107. READY = 1,
  65108. /**
  65109. * The asset is completely loaded.
  65110. */
  65111. COMPLETE = 2
  65112. }
  65113. /** @hidden */
  65114. export interface IGLTFLoader extends IDisposable {
  65115. readonly state: Nullable<GLTFLoaderState>;
  65116. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65117. meshes: AbstractMesh[];
  65118. particleSystems: IParticleSystem[];
  65119. skeletons: Skeleton[];
  65120. animationGroups: AnimationGroup[];
  65121. }>;
  65122. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65123. }
  65124. /**
  65125. * File loader for loading glTF files into a scene.
  65126. */
  65127. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65128. /** @hidden */
  65129. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65130. /** @hidden */
  65131. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65132. /**
  65133. * Raised when the asset has been parsed
  65134. */
  65135. onParsedObservable: Observable<IGLTFLoaderData>;
  65136. private _onParsedObserver;
  65137. /**
  65138. * Raised when the asset has been parsed
  65139. */
  65140. onParsed: (loaderData: IGLTFLoaderData) => void;
  65141. /**
  65142. * 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.
  65143. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65144. * Defaults to true.
  65145. * @hidden
  65146. */
  65147. static IncrementalLoading: boolean;
  65148. /**
  65149. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65150. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65151. * @hidden
  65152. */
  65153. static HomogeneousCoordinates: boolean;
  65154. /**
  65155. * The coordinate system mode. Defaults to AUTO.
  65156. */
  65157. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65158. /**
  65159. * The animation start mode. Defaults to FIRST.
  65160. */
  65161. animationStartMode: GLTFLoaderAnimationStartMode;
  65162. /**
  65163. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65164. */
  65165. compileMaterials: boolean;
  65166. /**
  65167. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65168. */
  65169. useClipPlane: boolean;
  65170. /**
  65171. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65172. */
  65173. compileShadowGenerators: boolean;
  65174. /**
  65175. * Defines if the Alpha blended materials are only applied as coverage.
  65176. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65177. * If true, no extra effects are applied to transparent pixels.
  65178. */
  65179. transparencyAsCoverage: boolean;
  65180. /**
  65181. * Function called before loading a url referenced by the asset.
  65182. */
  65183. preprocessUrlAsync: (url: string) => Promise<string>;
  65184. /**
  65185. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65186. */
  65187. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65188. private _onMeshLoadedObserver;
  65189. /**
  65190. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65191. */
  65192. onMeshLoaded: (mesh: AbstractMesh) => void;
  65193. /**
  65194. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65195. */
  65196. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65197. private _onTextureLoadedObserver;
  65198. /**
  65199. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65200. */
  65201. onTextureLoaded: (texture: BaseTexture) => void;
  65202. /**
  65203. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65204. */
  65205. readonly onMaterialLoadedObservable: Observable<Material>;
  65206. private _onMaterialLoadedObserver;
  65207. /**
  65208. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65209. */
  65210. onMaterialLoaded: (material: Material) => void;
  65211. /**
  65212. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65213. */
  65214. readonly onCameraLoadedObservable: Observable<Camera>;
  65215. private _onCameraLoadedObserver;
  65216. /**
  65217. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65218. */
  65219. onCameraLoaded: (camera: Camera) => void;
  65220. /**
  65221. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65222. * For assets with LODs, raised when all of the LODs are complete.
  65223. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65224. */
  65225. readonly onCompleteObservable: Observable<void>;
  65226. private _onCompleteObserver;
  65227. /**
  65228. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65229. * For assets with LODs, raised when all of the LODs are complete.
  65230. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65231. */
  65232. onComplete: () => void;
  65233. /**
  65234. * Observable raised when an error occurs.
  65235. */
  65236. readonly onErrorObservable: Observable<any>;
  65237. private _onErrorObserver;
  65238. /**
  65239. * Callback raised when an error occurs.
  65240. */
  65241. onError: (reason: any) => void;
  65242. /**
  65243. * Observable raised after the loader is disposed.
  65244. */
  65245. readonly onDisposeObservable: Observable<void>;
  65246. private _onDisposeObserver;
  65247. /**
  65248. * Callback raised after the loader is disposed.
  65249. */
  65250. onDispose: () => void;
  65251. /**
  65252. * Observable raised after a loader extension is created.
  65253. * Set additional options for a loader extension in this event.
  65254. */
  65255. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65256. private _onExtensionLoadedObserver;
  65257. /**
  65258. * Callback raised after a loader extension is created.
  65259. */
  65260. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65261. /**
  65262. * Defines if the loader logging is enabled.
  65263. */
  65264. loggingEnabled: boolean;
  65265. /**
  65266. * Defines if the loader should capture performance counters.
  65267. */
  65268. capturePerformanceCounters: boolean;
  65269. /**
  65270. * Defines if the loader should validate the asset.
  65271. */
  65272. validate: boolean;
  65273. /**
  65274. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65275. */
  65276. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65277. private _onValidatedObserver;
  65278. /**
  65279. * Callback raised after a loader extension is created.
  65280. */
  65281. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65282. private _loader;
  65283. /**
  65284. * Name of the loader ("gltf")
  65285. */
  65286. name: string;
  65287. /**
  65288. * Supported file extensions of the loader (.gltf, .glb)
  65289. */
  65290. extensions: ISceneLoaderPluginExtensions;
  65291. /**
  65292. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65293. */
  65294. dispose(): void;
  65295. /** @hidden */
  65296. _clear(): void;
  65297. /**
  65298. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65299. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65300. * @param scene the scene the meshes should be added to
  65301. * @param data the glTF data to load
  65302. * @param rootUrl root url to load from
  65303. * @param onProgress event that fires when loading progress has occured
  65304. * @param fileName Defines the name of the file to load
  65305. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65306. */
  65307. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65308. meshes: AbstractMesh[];
  65309. particleSystems: IParticleSystem[];
  65310. skeletons: Skeleton[];
  65311. animationGroups: AnimationGroup[];
  65312. }>;
  65313. /**
  65314. * Imports all objects from the loaded glTF data and adds them to the scene
  65315. * @param scene the scene the objects should be added to
  65316. * @param data the glTF data to load
  65317. * @param rootUrl root url to load from
  65318. * @param onProgress event that fires when loading progress has occured
  65319. * @param fileName Defines the name of the file to load
  65320. * @returns a promise which completes when objects have been loaded to the scene
  65321. */
  65322. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65323. /**
  65324. * Load into an asset container.
  65325. * @param scene The scene to load into
  65326. * @param data The data to import
  65327. * @param rootUrl The root url for scene and resources
  65328. * @param onProgress The callback when the load progresses
  65329. * @param fileName Defines the name of the file to load
  65330. * @returns The loaded asset container
  65331. */
  65332. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65333. /**
  65334. * If the data string can be loaded directly.
  65335. * @param data string contianing the file data
  65336. * @returns if the data can be loaded directly
  65337. */
  65338. canDirectLoad(data: string): boolean;
  65339. /**
  65340. * Rewrites a url by combining a root url and response url.
  65341. */
  65342. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65343. /**
  65344. * Instantiates a glTF file loader plugin.
  65345. * @returns the created plugin
  65346. */
  65347. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65348. /**
  65349. * The loader state or null if the loader is not active.
  65350. */
  65351. readonly loaderState: Nullable<GLTFLoaderState>;
  65352. /**
  65353. * Returns a promise that resolves when the asset is completely loaded.
  65354. * @returns a promise that resolves when the asset is completely loaded.
  65355. */
  65356. whenCompleteAsync(): Promise<void>;
  65357. private _parseAsync;
  65358. private _validateAsync;
  65359. private _getLoader;
  65360. private _unpackBinary;
  65361. private _unpackBinaryV1;
  65362. private _unpackBinaryV2;
  65363. private static _parseVersion;
  65364. private static _compareVersion;
  65365. private static _decodeBufferToText;
  65366. private static readonly _logSpaces;
  65367. private _logIndentLevel;
  65368. private _loggingEnabled;
  65369. /** @hidden */
  65370. _log: (message: string) => void;
  65371. /** @hidden */
  65372. _logOpen(message: string): void;
  65373. /** @hidden */
  65374. _logClose(): void;
  65375. private _logEnabled;
  65376. private _logDisabled;
  65377. private _capturePerformanceCounters;
  65378. /** @hidden */
  65379. _startPerformanceCounter: (counterName: string) => void;
  65380. /** @hidden */
  65381. _endPerformanceCounter: (counterName: string) => void;
  65382. private _startPerformanceCounterEnabled;
  65383. private _startPerformanceCounterDisabled;
  65384. private _endPerformanceCounterEnabled;
  65385. private _endPerformanceCounterDisabled;
  65386. }
  65387. }
  65388. declare module BABYLON.GLTF1 {
  65389. /**
  65390. * Enums
  65391. * @hidden
  65392. */
  65393. export enum EComponentType {
  65394. BYTE = 5120,
  65395. UNSIGNED_BYTE = 5121,
  65396. SHORT = 5122,
  65397. UNSIGNED_SHORT = 5123,
  65398. FLOAT = 5126
  65399. }
  65400. /** @hidden */
  65401. export enum EShaderType {
  65402. FRAGMENT = 35632,
  65403. VERTEX = 35633
  65404. }
  65405. /** @hidden */
  65406. export enum EParameterType {
  65407. BYTE = 5120,
  65408. UNSIGNED_BYTE = 5121,
  65409. SHORT = 5122,
  65410. UNSIGNED_SHORT = 5123,
  65411. INT = 5124,
  65412. UNSIGNED_INT = 5125,
  65413. FLOAT = 5126,
  65414. FLOAT_VEC2 = 35664,
  65415. FLOAT_VEC3 = 35665,
  65416. FLOAT_VEC4 = 35666,
  65417. INT_VEC2 = 35667,
  65418. INT_VEC3 = 35668,
  65419. INT_VEC4 = 35669,
  65420. BOOL = 35670,
  65421. BOOL_VEC2 = 35671,
  65422. BOOL_VEC3 = 35672,
  65423. BOOL_VEC4 = 35673,
  65424. FLOAT_MAT2 = 35674,
  65425. FLOAT_MAT3 = 35675,
  65426. FLOAT_MAT4 = 35676,
  65427. SAMPLER_2D = 35678
  65428. }
  65429. /** @hidden */
  65430. export enum ETextureWrapMode {
  65431. CLAMP_TO_EDGE = 33071,
  65432. MIRRORED_REPEAT = 33648,
  65433. REPEAT = 10497
  65434. }
  65435. /** @hidden */
  65436. export enum ETextureFilterType {
  65437. NEAREST = 9728,
  65438. LINEAR = 9728,
  65439. NEAREST_MIPMAP_NEAREST = 9984,
  65440. LINEAR_MIPMAP_NEAREST = 9985,
  65441. NEAREST_MIPMAP_LINEAR = 9986,
  65442. LINEAR_MIPMAP_LINEAR = 9987
  65443. }
  65444. /** @hidden */
  65445. export enum ETextureFormat {
  65446. ALPHA = 6406,
  65447. RGB = 6407,
  65448. RGBA = 6408,
  65449. LUMINANCE = 6409,
  65450. LUMINANCE_ALPHA = 6410
  65451. }
  65452. /** @hidden */
  65453. export enum ECullingType {
  65454. FRONT = 1028,
  65455. BACK = 1029,
  65456. FRONT_AND_BACK = 1032
  65457. }
  65458. /** @hidden */
  65459. export enum EBlendingFunction {
  65460. ZERO = 0,
  65461. ONE = 1,
  65462. SRC_COLOR = 768,
  65463. ONE_MINUS_SRC_COLOR = 769,
  65464. DST_COLOR = 774,
  65465. ONE_MINUS_DST_COLOR = 775,
  65466. SRC_ALPHA = 770,
  65467. ONE_MINUS_SRC_ALPHA = 771,
  65468. DST_ALPHA = 772,
  65469. ONE_MINUS_DST_ALPHA = 773,
  65470. CONSTANT_COLOR = 32769,
  65471. ONE_MINUS_CONSTANT_COLOR = 32770,
  65472. CONSTANT_ALPHA = 32771,
  65473. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65474. SRC_ALPHA_SATURATE = 776
  65475. }
  65476. /** @hidden */
  65477. export interface IGLTFProperty {
  65478. extensions?: {
  65479. [key: string]: any;
  65480. };
  65481. extras?: Object;
  65482. }
  65483. /** @hidden */
  65484. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65485. name?: string;
  65486. }
  65487. /** @hidden */
  65488. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65489. bufferView: string;
  65490. byteOffset: number;
  65491. byteStride: number;
  65492. count: number;
  65493. type: string;
  65494. componentType: EComponentType;
  65495. max?: number[];
  65496. min?: number[];
  65497. name?: string;
  65498. }
  65499. /** @hidden */
  65500. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65501. buffer: string;
  65502. byteOffset: number;
  65503. byteLength: number;
  65504. byteStride: number;
  65505. target?: number;
  65506. }
  65507. /** @hidden */
  65508. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65509. uri: string;
  65510. byteLength?: number;
  65511. type?: string;
  65512. }
  65513. /** @hidden */
  65514. export interface IGLTFShader extends IGLTFChildRootProperty {
  65515. uri: string;
  65516. type: EShaderType;
  65517. }
  65518. /** @hidden */
  65519. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65520. attributes: string[];
  65521. fragmentShader: string;
  65522. vertexShader: string;
  65523. }
  65524. /** @hidden */
  65525. export interface IGLTFTechniqueParameter {
  65526. type: number;
  65527. count?: number;
  65528. semantic?: string;
  65529. node?: string;
  65530. value?: number | boolean | string | Array<any>;
  65531. source?: string;
  65532. babylonValue?: any;
  65533. }
  65534. /** @hidden */
  65535. export interface IGLTFTechniqueCommonProfile {
  65536. lightingModel: string;
  65537. texcoordBindings: Object;
  65538. parameters?: Array<any>;
  65539. }
  65540. /** @hidden */
  65541. export interface IGLTFTechniqueStatesFunctions {
  65542. blendColor?: number[];
  65543. blendEquationSeparate?: number[];
  65544. blendFuncSeparate?: number[];
  65545. colorMask: boolean[];
  65546. cullFace: number[];
  65547. }
  65548. /** @hidden */
  65549. export interface IGLTFTechniqueStates {
  65550. enable: number[];
  65551. functions: IGLTFTechniqueStatesFunctions;
  65552. }
  65553. /** @hidden */
  65554. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65555. parameters: {
  65556. [key: string]: IGLTFTechniqueParameter;
  65557. };
  65558. program: string;
  65559. attributes: {
  65560. [key: string]: string;
  65561. };
  65562. uniforms: {
  65563. [key: string]: string;
  65564. };
  65565. states: IGLTFTechniqueStates;
  65566. }
  65567. /** @hidden */
  65568. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65569. technique?: string;
  65570. values: string[];
  65571. }
  65572. /** @hidden */
  65573. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65574. attributes: {
  65575. [key: string]: string;
  65576. };
  65577. indices: string;
  65578. material: string;
  65579. mode?: number;
  65580. }
  65581. /** @hidden */
  65582. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65583. primitives: IGLTFMeshPrimitive[];
  65584. }
  65585. /** @hidden */
  65586. export interface IGLTFImage extends IGLTFChildRootProperty {
  65587. uri: string;
  65588. }
  65589. /** @hidden */
  65590. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65591. magFilter?: number;
  65592. minFilter?: number;
  65593. wrapS?: number;
  65594. wrapT?: number;
  65595. }
  65596. /** @hidden */
  65597. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65598. sampler: string;
  65599. source: string;
  65600. format?: ETextureFormat;
  65601. internalFormat?: ETextureFormat;
  65602. target?: number;
  65603. type?: number;
  65604. babylonTexture?: Texture;
  65605. }
  65606. /** @hidden */
  65607. export interface IGLTFAmbienLight {
  65608. color?: number[];
  65609. }
  65610. /** @hidden */
  65611. export interface IGLTFDirectionalLight {
  65612. color?: number[];
  65613. }
  65614. /** @hidden */
  65615. export interface IGLTFPointLight {
  65616. color?: number[];
  65617. constantAttenuation?: number;
  65618. linearAttenuation?: number;
  65619. quadraticAttenuation?: number;
  65620. }
  65621. /** @hidden */
  65622. export interface IGLTFSpotLight {
  65623. color?: number[];
  65624. constantAttenuation?: number;
  65625. fallOfAngle?: number;
  65626. fallOffExponent?: number;
  65627. linearAttenuation?: number;
  65628. quadraticAttenuation?: number;
  65629. }
  65630. /** @hidden */
  65631. export interface IGLTFLight extends IGLTFChildRootProperty {
  65632. type: string;
  65633. }
  65634. /** @hidden */
  65635. export interface IGLTFCameraOrthographic {
  65636. xmag: number;
  65637. ymag: number;
  65638. zfar: number;
  65639. znear: number;
  65640. }
  65641. /** @hidden */
  65642. export interface IGLTFCameraPerspective {
  65643. aspectRatio: number;
  65644. yfov: number;
  65645. zfar: number;
  65646. znear: number;
  65647. }
  65648. /** @hidden */
  65649. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65650. type: string;
  65651. }
  65652. /** @hidden */
  65653. export interface IGLTFAnimationChannelTarget {
  65654. id: string;
  65655. path: string;
  65656. }
  65657. /** @hidden */
  65658. export interface IGLTFAnimationChannel {
  65659. sampler: string;
  65660. target: IGLTFAnimationChannelTarget;
  65661. }
  65662. /** @hidden */
  65663. export interface IGLTFAnimationSampler {
  65664. input: string;
  65665. output: string;
  65666. interpolation?: string;
  65667. }
  65668. /** @hidden */
  65669. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65670. channels?: IGLTFAnimationChannel[];
  65671. parameters?: {
  65672. [key: string]: string;
  65673. };
  65674. samplers?: {
  65675. [key: string]: IGLTFAnimationSampler;
  65676. };
  65677. }
  65678. /** @hidden */
  65679. export interface IGLTFNodeInstanceSkin {
  65680. skeletons: string[];
  65681. skin: string;
  65682. meshes: string[];
  65683. }
  65684. /** @hidden */
  65685. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65686. bindShapeMatrix: number[];
  65687. inverseBindMatrices: string;
  65688. jointNames: string[];
  65689. babylonSkeleton?: Skeleton;
  65690. }
  65691. /** @hidden */
  65692. export interface IGLTFNode extends IGLTFChildRootProperty {
  65693. camera?: string;
  65694. children: string[];
  65695. skin?: string;
  65696. jointName?: string;
  65697. light?: string;
  65698. matrix: number[];
  65699. mesh?: string;
  65700. meshes?: string[];
  65701. rotation?: number[];
  65702. scale?: number[];
  65703. translation?: number[];
  65704. babylonNode?: Node;
  65705. }
  65706. /** @hidden */
  65707. export interface IGLTFScene extends IGLTFChildRootProperty {
  65708. nodes: string[];
  65709. }
  65710. /** @hidden */
  65711. export interface IGLTFRuntime {
  65712. extensions: {
  65713. [key: string]: any;
  65714. };
  65715. accessors: {
  65716. [key: string]: IGLTFAccessor;
  65717. };
  65718. buffers: {
  65719. [key: string]: IGLTFBuffer;
  65720. };
  65721. bufferViews: {
  65722. [key: string]: IGLTFBufferView;
  65723. };
  65724. meshes: {
  65725. [key: string]: IGLTFMesh;
  65726. };
  65727. lights: {
  65728. [key: string]: IGLTFLight;
  65729. };
  65730. cameras: {
  65731. [key: string]: IGLTFCamera;
  65732. };
  65733. nodes: {
  65734. [key: string]: IGLTFNode;
  65735. };
  65736. images: {
  65737. [key: string]: IGLTFImage;
  65738. };
  65739. textures: {
  65740. [key: string]: IGLTFTexture;
  65741. };
  65742. shaders: {
  65743. [key: string]: IGLTFShader;
  65744. };
  65745. programs: {
  65746. [key: string]: IGLTFProgram;
  65747. };
  65748. samplers: {
  65749. [key: string]: IGLTFSampler;
  65750. };
  65751. techniques: {
  65752. [key: string]: IGLTFTechnique;
  65753. };
  65754. materials: {
  65755. [key: string]: IGLTFMaterial;
  65756. };
  65757. animations: {
  65758. [key: string]: IGLTFAnimation;
  65759. };
  65760. skins: {
  65761. [key: string]: IGLTFSkins;
  65762. };
  65763. currentScene?: Object;
  65764. scenes: {
  65765. [key: string]: IGLTFScene;
  65766. };
  65767. extensionsUsed: string[];
  65768. extensionsRequired?: string[];
  65769. buffersCount: number;
  65770. shaderscount: number;
  65771. scene: Scene;
  65772. rootUrl: string;
  65773. loadedBufferCount: number;
  65774. loadedBufferViews: {
  65775. [name: string]: ArrayBufferView;
  65776. };
  65777. loadedShaderCount: number;
  65778. importOnlyMeshes: boolean;
  65779. importMeshesNames?: string[];
  65780. dummyNodes: Node[];
  65781. }
  65782. /** @hidden */
  65783. export interface INodeToRoot {
  65784. bone: Bone;
  65785. node: IGLTFNode;
  65786. id: string;
  65787. }
  65788. /** @hidden */
  65789. export interface IJointNode {
  65790. node: IGLTFNode;
  65791. id: string;
  65792. }
  65793. }
  65794. declare module BABYLON.GLTF1 {
  65795. /**
  65796. * Utils functions for GLTF
  65797. * @hidden
  65798. */
  65799. export class GLTFUtils {
  65800. /**
  65801. * Sets the given "parameter" matrix
  65802. * @param scene: the Scene object
  65803. * @param source: the source node where to pick the matrix
  65804. * @param parameter: the GLTF technique parameter
  65805. * @param uniformName: the name of the shader's uniform
  65806. * @param shaderMaterial: the shader material
  65807. */
  65808. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65809. /**
  65810. * Sets the given "parameter" matrix
  65811. * @param shaderMaterial: the shader material
  65812. * @param uniform: the name of the shader's uniform
  65813. * @param value: the value of the uniform
  65814. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65815. */
  65816. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65817. /**
  65818. * Returns the wrap mode of the texture
  65819. * @param mode: the mode value
  65820. */
  65821. static GetWrapMode(mode: number): number;
  65822. /**
  65823. * Returns the byte stride giving an accessor
  65824. * @param accessor: the GLTF accessor objet
  65825. */
  65826. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65827. /**
  65828. * Returns the texture filter mode giving a mode value
  65829. * @param mode: the filter mode value
  65830. */
  65831. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65832. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65833. /**
  65834. * Returns a buffer from its accessor
  65835. * @param gltfRuntime: the GLTF runtime
  65836. * @param accessor: the GLTF accessor
  65837. */
  65838. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65839. /**
  65840. * Decodes a buffer view into a string
  65841. * @param view: the buffer view
  65842. */
  65843. static DecodeBufferToText(view: ArrayBufferView): string;
  65844. /**
  65845. * Returns the default material of gltf. Related to
  65846. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65847. * @param scene: the Babylon.js scene
  65848. */
  65849. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65850. private static _DefaultMaterial;
  65851. }
  65852. }
  65853. declare module BABYLON.GLTF1 {
  65854. /**
  65855. * Implementation of the base glTF spec
  65856. * @hidden
  65857. */
  65858. export class GLTFLoaderBase {
  65859. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65860. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65861. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65862. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65863. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65864. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65865. }
  65866. /**
  65867. * glTF V1 Loader
  65868. * @hidden
  65869. */
  65870. export class GLTFLoader implements IGLTFLoader {
  65871. static Extensions: {
  65872. [name: string]: GLTFLoaderExtension;
  65873. };
  65874. static RegisterExtension(extension: GLTFLoaderExtension): void;
  65875. state: Nullable<GLTFLoaderState>;
  65876. dispose(): void;
  65877. private _importMeshAsync;
  65878. /**
  65879. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  65880. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65881. * @param scene the scene the meshes should be added to
  65882. * @param data gltf data containing information of the meshes in a loaded file
  65883. * @param rootUrl root url to load from
  65884. * @param onProgress event that fires when loading progress has occured
  65885. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65886. */
  65887. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  65888. meshes: AbstractMesh[];
  65889. particleSystems: IParticleSystem[];
  65890. skeletons: Skeleton[];
  65891. animationGroups: AnimationGroup[];
  65892. }>;
  65893. private _loadAsync;
  65894. /**
  65895. * Imports all objects from a loaded gltf file and adds them to the scene
  65896. * @param scene the scene the objects should be added to
  65897. * @param data gltf data containing information of the meshes in a loaded file
  65898. * @param rootUrl root url to load from
  65899. * @param onProgress event that fires when loading progress has occured
  65900. * @returns a promise which completes when objects have been loaded to the scene
  65901. */
  65902. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  65903. private _loadShadersAsync;
  65904. private _loadBuffersAsync;
  65905. private _createNodes;
  65906. }
  65907. /** @hidden */
  65908. export abstract class GLTFLoaderExtension {
  65909. private _name;
  65910. constructor(name: string);
  65911. readonly name: string;
  65912. /**
  65913. * Defines an override for loading the runtime
  65914. * Return true to stop further extensions from loading the runtime
  65915. */
  65916. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  65917. /**
  65918. * Defines an onverride for creating gltf runtime
  65919. * Return true to stop further extensions from creating the runtime
  65920. */
  65921. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  65922. /**
  65923. * Defines an override for loading buffers
  65924. * Return true to stop further extensions from loading this buffer
  65925. */
  65926. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  65927. /**
  65928. * Defines an override for loading texture buffers
  65929. * Return true to stop further extensions from loading this texture data
  65930. */
  65931. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65932. /**
  65933. * Defines an override for creating textures
  65934. * Return true to stop further extensions from loading this texture
  65935. */
  65936. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  65937. /**
  65938. * Defines an override for loading shader strings
  65939. * Return true to stop further extensions from loading this shader data
  65940. */
  65941. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65942. /**
  65943. * Defines an override for loading materials
  65944. * Return true to stop further extensions from loading this material
  65945. */
  65946. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65947. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  65948. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  65949. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65950. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65951. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  65952. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65953. private static LoadTextureBufferAsync;
  65954. private static CreateTextureAsync;
  65955. private static ApplyExtensions;
  65956. }
  65957. }
  65958. declare module BABYLON.GLTF1 {
  65959. /** @hidden */
  65960. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  65961. private _bin;
  65962. constructor();
  65963. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  65964. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65965. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65966. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65967. }
  65968. }
  65969. declare module BABYLON.GLTF1 {
  65970. /** @hidden */
  65971. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  65972. constructor();
  65973. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  65974. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65975. private _loadTexture;
  65976. }
  65977. }
  65978. declare module BABYLON.GLTF2.Loader {
  65979. /**
  65980. * Loader interface with an index field.
  65981. */
  65982. export interface IArrayItem {
  65983. /**
  65984. * The index of this item in the array.
  65985. */
  65986. index: number;
  65987. }
  65988. /**
  65989. * Loader interface with additional members.
  65990. */
  65991. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  65992. /** @hidden */
  65993. _data?: Promise<ArrayBufferView>;
  65994. /** @hidden */
  65995. _babylonVertexBuffer?: Promise<VertexBuffer>;
  65996. }
  65997. /**
  65998. * Loader interface with additional members.
  65999. */
  66000. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66001. }
  66002. /** @hidden */
  66003. export interface _IAnimationSamplerData {
  66004. input: Float32Array;
  66005. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66006. output: Float32Array;
  66007. }
  66008. /**
  66009. * Loader interface with additional members.
  66010. */
  66011. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66012. /** @hidden */
  66013. _data?: Promise<_IAnimationSamplerData>;
  66014. }
  66015. /**
  66016. * Loader interface with additional members.
  66017. */
  66018. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66019. channels: IAnimationChannel[];
  66020. samplers: IAnimationSampler[];
  66021. /** @hidden */
  66022. _babylonAnimationGroup?: AnimationGroup;
  66023. }
  66024. /**
  66025. * Loader interface with additional members.
  66026. */
  66027. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66028. /** @hidden */
  66029. _data?: Promise<ArrayBufferView>;
  66030. }
  66031. /**
  66032. * Loader interface with additional members.
  66033. */
  66034. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66035. /** @hidden */
  66036. _data?: Promise<ArrayBufferView>;
  66037. /** @hidden */
  66038. _babylonBuffer?: Promise<Buffer>;
  66039. }
  66040. /**
  66041. * Loader interface with additional members.
  66042. */
  66043. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66044. }
  66045. /**
  66046. * Loader interface with additional members.
  66047. */
  66048. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66049. /** @hidden */
  66050. _data?: Promise<ArrayBufferView>;
  66051. }
  66052. /**
  66053. * Loader interface with additional members.
  66054. */
  66055. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66056. }
  66057. /**
  66058. * Loader interface with additional members.
  66059. */
  66060. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66061. }
  66062. /**
  66063. * Loader interface with additional members.
  66064. */
  66065. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66066. baseColorTexture?: ITextureInfo;
  66067. metallicRoughnessTexture?: ITextureInfo;
  66068. }
  66069. /**
  66070. * Loader interface with additional members.
  66071. */
  66072. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66073. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66074. normalTexture?: IMaterialNormalTextureInfo;
  66075. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66076. emissiveTexture?: ITextureInfo;
  66077. /** @hidden */
  66078. _data?: {
  66079. [babylonDrawMode: number]: {
  66080. babylonMaterial: Material;
  66081. babylonMeshes: AbstractMesh[];
  66082. promise: Promise<void>;
  66083. };
  66084. };
  66085. }
  66086. /**
  66087. * Loader interface with additional members.
  66088. */
  66089. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66090. primitives: IMeshPrimitive[];
  66091. }
  66092. /**
  66093. * Loader interface with additional members.
  66094. */
  66095. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66096. /** @hidden */
  66097. _instanceData?: {
  66098. babylonSourceMesh: Mesh;
  66099. promise: Promise<any>;
  66100. };
  66101. }
  66102. /**
  66103. * Loader interface with additional members.
  66104. */
  66105. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66106. /**
  66107. * The parent glTF node.
  66108. */
  66109. parent?: INode;
  66110. /** @hidden */
  66111. _babylonTransformNode?: TransformNode;
  66112. /** @hidden */
  66113. _primitiveBabylonMeshes?: AbstractMesh[];
  66114. /** @hidden */
  66115. _babylonBones?: Bone[];
  66116. /** @hidden */
  66117. _numMorphTargets?: number;
  66118. }
  66119. /** @hidden */
  66120. export interface _ISamplerData {
  66121. noMipMaps: boolean;
  66122. samplingMode: number;
  66123. wrapU: number;
  66124. wrapV: number;
  66125. }
  66126. /**
  66127. * Loader interface with additional members.
  66128. */
  66129. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66130. /** @hidden */
  66131. _data?: _ISamplerData;
  66132. }
  66133. /**
  66134. * Loader interface with additional members.
  66135. */
  66136. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66137. }
  66138. /**
  66139. * Loader interface with additional members.
  66140. */
  66141. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66142. /** @hidden */
  66143. _data?: {
  66144. babylonSkeleton: Skeleton;
  66145. promise: Promise<void>;
  66146. };
  66147. }
  66148. /**
  66149. * Loader interface with additional members.
  66150. */
  66151. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66152. }
  66153. /**
  66154. * Loader interface with additional members.
  66155. */
  66156. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66157. }
  66158. /**
  66159. * Loader interface with additional members.
  66160. */
  66161. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66162. accessors?: IAccessor[];
  66163. animations?: IAnimation[];
  66164. buffers?: IBuffer[];
  66165. bufferViews?: IBufferView[];
  66166. cameras?: ICamera[];
  66167. images?: IImage[];
  66168. materials?: IMaterial[];
  66169. meshes?: IMesh[];
  66170. nodes?: INode[];
  66171. samplers?: ISampler[];
  66172. scenes?: IScene[];
  66173. skins?: ISkin[];
  66174. textures?: ITexture[];
  66175. }
  66176. }
  66177. declare module BABYLON.GLTF2 {
  66178. /**
  66179. * Interface for a glTF loader extension.
  66180. */
  66181. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66182. /**
  66183. * Called after the loader state changes to LOADING.
  66184. */
  66185. onLoading?(): void;
  66186. /**
  66187. * Called after the loader state changes to READY.
  66188. */
  66189. onReady?(): void;
  66190. /**
  66191. * Define this method to modify the default behavior when loading scenes.
  66192. * @param context The context when loading the asset
  66193. * @param scene The glTF scene property
  66194. * @returns A promise that resolves when the load is complete or null if not handled
  66195. */
  66196. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66197. /**
  66198. * Define this method to modify the default behavior when loading nodes.
  66199. * @param context The context when loading the asset
  66200. * @param node The glTF node property
  66201. * @param assign A function called synchronously after parsing the glTF properties
  66202. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66203. */
  66204. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66205. /**
  66206. * Define this method to modify the default behavior when loading cameras.
  66207. * @param context The context when loading the asset
  66208. * @param camera The glTF camera property
  66209. * @param assign A function called synchronously after parsing the glTF properties
  66210. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66211. */
  66212. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66213. /**
  66214. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66215. * @param context The context when loading the asset
  66216. * @param primitive The glTF mesh primitive property
  66217. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66218. */
  66219. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66220. /**
  66221. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66222. * @param context The context when loading the asset
  66223. * @param name The mesh name when loading the asset
  66224. * @param node The glTF node when loading the asset
  66225. * @param mesh The glTF mesh when loading the asset
  66226. * @param primitive The glTF mesh primitive property
  66227. * @param assign A function called synchronously after parsing the glTF properties
  66228. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66229. */
  66230. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66231. /**
  66232. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66233. * @param context The context when loading the asset
  66234. * @param material The glTF material property
  66235. * @param assign A function called synchronously after parsing the glTF properties
  66236. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66237. */
  66238. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66239. /**
  66240. * Define this method to modify the default behavior when creating materials.
  66241. * @param context The context when loading the asset
  66242. * @param material The glTF material property
  66243. * @param babylonDrawMode The draw mode for the Babylon material
  66244. * @returns The Babylon material or null if not handled
  66245. */
  66246. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66247. /**
  66248. * Define this method to modify the default behavior when loading material properties.
  66249. * @param context The context when loading the asset
  66250. * @param material The glTF material property
  66251. * @param babylonMaterial The Babylon material
  66252. * @returns A promise that resolves when the load is complete or null if not handled
  66253. */
  66254. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66255. /**
  66256. * Define this method to modify the default behavior when loading texture infos.
  66257. * @param context The context when loading the asset
  66258. * @param textureInfo The glTF texture info property
  66259. * @param assign A function called synchronously after parsing the glTF properties
  66260. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66261. */
  66262. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66263. /**
  66264. * Define this method to modify the default behavior when loading animations.
  66265. * @param context The context when loading the asset
  66266. * @param animation The glTF animation property
  66267. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66268. */
  66269. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66270. /**
  66271. * @hidden Define this method to modify the default behavior when loading skins.
  66272. * @param context The context when loading the asset
  66273. * @param node The glTF node property
  66274. * @param skin The glTF skin property
  66275. * @returns A promise that resolves when the load is complete or null if not handled
  66276. */
  66277. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66278. /**
  66279. * @hidden Define this method to modify the default behavior when loading uris.
  66280. * @param context The context when loading the asset
  66281. * @param property The glTF property associated with the uri
  66282. * @param uri The uri to load
  66283. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66284. */
  66285. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66286. }
  66287. }
  66288. declare module BABYLON.GLTF2 {
  66289. /**
  66290. * Helper class for working with arrays when loading the glTF asset
  66291. */
  66292. export class ArrayItem {
  66293. /**
  66294. * Gets an item from the given array.
  66295. * @param context The context when loading the asset
  66296. * @param array The array to get the item from
  66297. * @param index The index to the array
  66298. * @returns The array item
  66299. */
  66300. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66301. /**
  66302. * Assign an `index` field to each item of the given array.
  66303. * @param array The array of items
  66304. */
  66305. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66306. }
  66307. /**
  66308. * The glTF 2.0 loader
  66309. */
  66310. export class GLTFLoader implements IGLTFLoader {
  66311. /** @hidden */
  66312. _completePromises: Promise<any>[];
  66313. private _disposed;
  66314. private _parent;
  66315. private _state;
  66316. private _extensions;
  66317. private _rootUrl;
  66318. private _fileName;
  66319. private _uniqueRootUrl;
  66320. private _gltf;
  66321. private _babylonScene;
  66322. private _rootBabylonMesh;
  66323. private _defaultBabylonMaterialData;
  66324. private _progressCallback?;
  66325. private _requests;
  66326. private static readonly _DefaultSampler;
  66327. private static _ExtensionNames;
  66328. private static _ExtensionFactories;
  66329. /**
  66330. * Registers a loader extension.
  66331. * @param name The name of the loader extension.
  66332. * @param factory The factory function that creates the loader extension.
  66333. */
  66334. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66335. /**
  66336. * Unregisters a loader extension.
  66337. * @param name The name of the loader extenion.
  66338. * @returns A boolean indicating whether the extension has been unregistered
  66339. */
  66340. static UnregisterExtension(name: string): boolean;
  66341. /**
  66342. * Gets the loader state.
  66343. */
  66344. readonly state: Nullable<GLTFLoaderState>;
  66345. /**
  66346. * The glTF object parsed from the JSON.
  66347. */
  66348. readonly gltf: IGLTF;
  66349. /**
  66350. * The Babylon scene when loading the asset.
  66351. */
  66352. readonly babylonScene: Scene;
  66353. /**
  66354. * The root Babylon mesh when loading the asset.
  66355. */
  66356. readonly rootBabylonMesh: Mesh;
  66357. /** @hidden */
  66358. constructor(parent: GLTFFileLoader);
  66359. /** @hidden */
  66360. dispose(): void;
  66361. /** @hidden */
  66362. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66363. meshes: AbstractMesh[];
  66364. particleSystems: IParticleSystem[];
  66365. skeletons: Skeleton[];
  66366. animationGroups: AnimationGroup[];
  66367. }>;
  66368. /** @hidden */
  66369. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66370. private _loadAsync;
  66371. private _loadData;
  66372. private _setupData;
  66373. private _loadExtensions;
  66374. private _checkExtensions;
  66375. private _setState;
  66376. private _createRootNode;
  66377. /**
  66378. * Loads a glTF scene.
  66379. * @param context The context when loading the asset
  66380. * @param scene The glTF scene property
  66381. * @returns A promise that resolves when the load is complete
  66382. */
  66383. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66384. private _forEachPrimitive;
  66385. private _getMeshes;
  66386. private _getSkeletons;
  66387. private _getAnimationGroups;
  66388. private _startAnimations;
  66389. /**
  66390. * Loads a glTF node.
  66391. * @param context The context when loading the asset
  66392. * @param node The glTF node property
  66393. * @param assign A function called synchronously after parsing the glTF properties
  66394. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66395. */
  66396. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66397. private _loadMeshAsync;
  66398. /**
  66399. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66400. * @param context The context when loading the asset
  66401. * @param name The mesh name when loading the asset
  66402. * @param node The glTF node when loading the asset
  66403. * @param mesh The glTF mesh when loading the asset
  66404. * @param primitive The glTF mesh primitive property
  66405. * @param assign A function called synchronously after parsing the glTF properties
  66406. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66407. */
  66408. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66409. private _loadVertexDataAsync;
  66410. private _createMorphTargets;
  66411. private _loadMorphTargetsAsync;
  66412. private _loadMorphTargetVertexDataAsync;
  66413. private static _LoadTransform;
  66414. private _loadSkinAsync;
  66415. private _loadBones;
  66416. private _loadBone;
  66417. private _loadSkinInverseBindMatricesDataAsync;
  66418. private _updateBoneMatrices;
  66419. private _getNodeMatrix;
  66420. /**
  66421. * Loads a glTF camera.
  66422. * @param context The context when loading the asset
  66423. * @param camera The glTF camera property
  66424. * @param assign A function called synchronously after parsing the glTF properties
  66425. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66426. */
  66427. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66428. private _loadAnimationsAsync;
  66429. /**
  66430. * Loads a glTF animation.
  66431. * @param context The context when loading the asset
  66432. * @param animation The glTF animation property
  66433. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66434. */
  66435. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66436. /**
  66437. * @hidden Loads a glTF animation channel.
  66438. * @param context The context when loading the asset
  66439. * @param animationContext The context of the animation when loading the asset
  66440. * @param animation The glTF animation property
  66441. * @param channel The glTF animation channel property
  66442. * @param babylonAnimationGroup The babylon animation group property
  66443. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66444. * @returns A void promise when the channel load is complete
  66445. */
  66446. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66447. private _loadAnimationSamplerAsync;
  66448. private _loadBufferAsync;
  66449. /**
  66450. * Loads a glTF buffer view.
  66451. * @param context The context when loading the asset
  66452. * @param bufferView The glTF buffer view property
  66453. * @returns A promise that resolves with the loaded data when the load is complete
  66454. */
  66455. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66456. private _loadAccessorAsync;
  66457. private _loadFloatAccessorAsync;
  66458. private _loadIndicesAccessorAsync;
  66459. private _loadVertexBufferViewAsync;
  66460. private _loadVertexAccessorAsync;
  66461. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66462. /** @hidden */
  66463. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66464. private _createDefaultMaterial;
  66465. /**
  66466. * Creates a Babylon material from a glTF material.
  66467. * @param context The context when loading the asset
  66468. * @param material The glTF material property
  66469. * @param babylonDrawMode The draw mode for the Babylon material
  66470. * @returns The Babylon material
  66471. */
  66472. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66473. /**
  66474. * Loads properties from a glTF material into a Babylon material.
  66475. * @param context The context when loading the asset
  66476. * @param material The glTF material property
  66477. * @param babylonMaterial The Babylon material
  66478. * @returns A promise that resolves when the load is complete
  66479. */
  66480. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66481. /**
  66482. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66483. * @param context The context when loading the asset
  66484. * @param material The glTF material property
  66485. * @param babylonMaterial The Babylon material
  66486. * @returns A promise that resolves when the load is complete
  66487. */
  66488. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66489. /**
  66490. * Loads the alpha properties from a glTF material into a Babylon material.
  66491. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66492. * @param context The context when loading the asset
  66493. * @param material The glTF material property
  66494. * @param babylonMaterial The Babylon material
  66495. */
  66496. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66497. /**
  66498. * Loads a glTF texture info.
  66499. * @param context The context when loading the asset
  66500. * @param textureInfo The glTF texture info property
  66501. * @param assign A function called synchronously after parsing the glTF properties
  66502. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66503. */
  66504. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66505. private _loadTextureAsync;
  66506. private _loadSampler;
  66507. /**
  66508. * Loads a glTF image.
  66509. * @param context The context when loading the asset
  66510. * @param image The glTF image property
  66511. * @returns A promise that resolves with the loaded data when the load is complete
  66512. */
  66513. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66514. /**
  66515. * Loads a glTF uri.
  66516. * @param context The context when loading the asset
  66517. * @param property The glTF property associated with the uri
  66518. * @param uri The base64 or relative uri
  66519. * @returns A promise that resolves with the loaded data when the load is complete
  66520. */
  66521. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66522. private _onProgress;
  66523. /**
  66524. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66525. * @param babylonObject the Babylon object with metadata
  66526. * @param pointer the JSON pointer
  66527. */
  66528. static AddPointerMetadata(babylonObject: {
  66529. metadata: any;
  66530. }, pointer: string): void;
  66531. private static _GetTextureWrapMode;
  66532. private static _GetTextureSamplingMode;
  66533. private static _GetTypedArrayConstructor;
  66534. private static _GetTypedArray;
  66535. private static _GetNumComponents;
  66536. private static _ValidateUri;
  66537. private static _GetDrawMode;
  66538. private _compileMaterialsAsync;
  66539. private _compileShadowGeneratorsAsync;
  66540. private _forEachExtensions;
  66541. private _applyExtensions;
  66542. private _extensionsOnLoading;
  66543. private _extensionsOnReady;
  66544. private _extensionsLoadSceneAsync;
  66545. private _extensionsLoadNodeAsync;
  66546. private _extensionsLoadCameraAsync;
  66547. private _extensionsLoadVertexDataAsync;
  66548. private _extensionsLoadMeshPrimitiveAsync;
  66549. private _extensionsLoadMaterialAsync;
  66550. private _extensionsCreateMaterial;
  66551. private _extensionsLoadMaterialPropertiesAsync;
  66552. private _extensionsLoadTextureInfoAsync;
  66553. private _extensionsLoadAnimationAsync;
  66554. private _extensionsLoadSkinAsync;
  66555. private _extensionsLoadUriAsync;
  66556. /**
  66557. * Helper method called by a loader extension to load an glTF extension.
  66558. * @param context The context when loading the asset
  66559. * @param property The glTF property to load the extension from
  66560. * @param extensionName The name of the extension to load
  66561. * @param actionAsync The action to run
  66562. * @returns The promise returned by actionAsync or null if the extension does not exist
  66563. */
  66564. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66565. /**
  66566. * Helper method called by a loader extension to load a glTF extra.
  66567. * @param context The context when loading the asset
  66568. * @param property The glTF property to load the extra from
  66569. * @param extensionName The name of the extension to load
  66570. * @param actionAsync The action to run
  66571. * @returns The promise returned by actionAsync or null if the extra does not exist
  66572. */
  66573. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66574. /**
  66575. * Increments the indentation level and logs a message.
  66576. * @param message The message to log
  66577. */
  66578. logOpen(message: string): void;
  66579. /**
  66580. * Decrements the indentation level.
  66581. */
  66582. logClose(): void;
  66583. /**
  66584. * Logs a message
  66585. * @param message The message to log
  66586. */
  66587. log(message: string): void;
  66588. /**
  66589. * Starts a performance counter.
  66590. * @param counterName The name of the performance counter
  66591. */
  66592. startPerformanceCounter(counterName: string): void;
  66593. /**
  66594. * Ends a performance counter.
  66595. * @param counterName The name of the performance counter
  66596. */
  66597. endPerformanceCounter(counterName: string): void;
  66598. }
  66599. }
  66600. declare module BABYLON.GLTF2.Loader.Extensions {
  66601. /**
  66602. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66603. */
  66604. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66605. /** The name of this extension. */
  66606. readonly name: string;
  66607. /** Defines whether this extension is enabled. */
  66608. enabled: boolean;
  66609. private _loader;
  66610. private _lights?;
  66611. /** @hidden */
  66612. constructor(loader: GLTFLoader);
  66613. /** @hidden */
  66614. dispose(): void;
  66615. /** @hidden */
  66616. onLoading(): void;
  66617. /** @hidden */
  66618. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66619. private _loadLightAsync;
  66620. }
  66621. }
  66622. declare module BABYLON.GLTF2.Loader.Extensions {
  66623. /**
  66624. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66625. */
  66626. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66627. /** The name of this extension. */
  66628. readonly name: string;
  66629. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66630. dracoCompression?: DracoCompression;
  66631. /** Defines whether this extension is enabled. */
  66632. enabled: boolean;
  66633. private _loader;
  66634. /** @hidden */
  66635. constructor(loader: GLTFLoader);
  66636. /** @hidden */
  66637. dispose(): void;
  66638. /** @hidden */
  66639. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66640. }
  66641. }
  66642. declare module BABYLON.GLTF2.Loader.Extensions {
  66643. /**
  66644. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66645. */
  66646. export class KHR_lights implements IGLTFLoaderExtension {
  66647. /** The name of this extension. */
  66648. readonly name: string;
  66649. /** Defines whether this extension is enabled. */
  66650. enabled: boolean;
  66651. private _loader;
  66652. private _lights?;
  66653. /** @hidden */
  66654. constructor(loader: GLTFLoader);
  66655. /** @hidden */
  66656. dispose(): void;
  66657. /** @hidden */
  66658. onLoading(): void;
  66659. /** @hidden */
  66660. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66661. }
  66662. }
  66663. declare module BABYLON.GLTF2.Loader.Extensions {
  66664. /**
  66665. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66666. */
  66667. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66668. /** The name of this extension. */
  66669. readonly name: string;
  66670. /** Defines whether this extension is enabled. */
  66671. enabled: boolean;
  66672. private _loader;
  66673. /** @hidden */
  66674. constructor(loader: GLTFLoader);
  66675. /** @hidden */
  66676. dispose(): void;
  66677. /** @hidden */
  66678. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66679. private _loadSpecularGlossinessPropertiesAsync;
  66680. }
  66681. }
  66682. declare module BABYLON.GLTF2.Loader.Extensions {
  66683. /**
  66684. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66685. */
  66686. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66687. /** The name of this extension. */
  66688. readonly name: string;
  66689. /** Defines whether this extension is enabled. */
  66690. enabled: boolean;
  66691. private _loader;
  66692. /** @hidden */
  66693. constructor(loader: GLTFLoader);
  66694. /** @hidden */
  66695. dispose(): void;
  66696. /** @hidden */
  66697. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66698. private _loadUnlitPropertiesAsync;
  66699. }
  66700. }
  66701. declare module BABYLON.GLTF2.Loader.Extensions {
  66702. /**
  66703. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66704. */
  66705. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66706. /** The name of this extension. */
  66707. readonly name: string;
  66708. /** Defines whether this extension is enabled. */
  66709. enabled: boolean;
  66710. private _loader;
  66711. /** @hidden */
  66712. constructor(loader: GLTFLoader);
  66713. /** @hidden */
  66714. dispose(): void;
  66715. /** @hidden */
  66716. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66717. }
  66718. }
  66719. declare module BABYLON.GLTF2.Loader.Extensions {
  66720. /**
  66721. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66722. */
  66723. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66724. /** The name of this extension. */
  66725. readonly name: string;
  66726. /** Defines whether this extension is enabled. */
  66727. enabled: boolean;
  66728. private _loader;
  66729. private _clips;
  66730. private _emitters;
  66731. /** @hidden */
  66732. constructor(loader: GLTFLoader);
  66733. /** @hidden */
  66734. dispose(): void;
  66735. /** @hidden */
  66736. onLoading(): void;
  66737. /** @hidden */
  66738. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66739. /** @hidden */
  66740. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66741. /** @hidden */
  66742. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66743. private _loadClipAsync;
  66744. private _loadEmitterAsync;
  66745. private _getEventAction;
  66746. private _loadAnimationEventAsync;
  66747. }
  66748. }
  66749. declare module BABYLON.GLTF2.Loader.Extensions {
  66750. /**
  66751. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66752. */
  66753. export class MSFT_lod implements IGLTFLoaderExtension {
  66754. /** The name of this extension. */
  66755. readonly name: string;
  66756. /** Defines whether this extension is enabled. */
  66757. enabled: boolean;
  66758. /**
  66759. * Maximum number of LODs to load, starting from the lowest LOD.
  66760. */
  66761. maxLODsToLoad: number;
  66762. /**
  66763. * Observable raised when all node LODs of one level are loaded.
  66764. * The event data is the index of the loaded LOD starting from zero.
  66765. * Dispose the loader to cancel the loading of the next level of LODs.
  66766. */
  66767. onNodeLODsLoadedObservable: Observable<number>;
  66768. /**
  66769. * Observable raised when all material LODs of one level are loaded.
  66770. * The event data is the index of the loaded LOD starting from zero.
  66771. * Dispose the loader to cancel the loading of the next level of LODs.
  66772. */
  66773. onMaterialLODsLoadedObservable: Observable<number>;
  66774. private _loader;
  66775. private _nodeIndexLOD;
  66776. private _nodeSignalLODs;
  66777. private _nodePromiseLODs;
  66778. private _materialIndexLOD;
  66779. private _materialSignalLODs;
  66780. private _materialPromiseLODs;
  66781. /** @hidden */
  66782. constructor(loader: GLTFLoader);
  66783. /** @hidden */
  66784. dispose(): void;
  66785. /** @hidden */
  66786. onReady(): void;
  66787. /** @hidden */
  66788. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66789. /** @hidden */
  66790. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66791. /** @hidden */
  66792. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66793. /**
  66794. * Gets an array of LOD properties from lowest to highest.
  66795. */
  66796. private _getLODs;
  66797. private _disposeUnusedMaterials;
  66798. }
  66799. }
  66800. declare module BABYLON.GLTF2.Loader.Extensions {
  66801. /** @hidden */
  66802. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66803. readonly name: string;
  66804. enabled: boolean;
  66805. private _loader;
  66806. constructor(loader: GLTFLoader);
  66807. dispose(): void;
  66808. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66809. }
  66810. }
  66811. declare module BABYLON.GLTF2.Loader.Extensions {
  66812. /** @hidden */
  66813. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66814. readonly name: string;
  66815. enabled: boolean;
  66816. private _loader;
  66817. constructor(loader: GLTFLoader);
  66818. dispose(): void;
  66819. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66820. }
  66821. }
  66822. declare module BABYLON.GLTF2.Loader.Extensions {
  66823. /**
  66824. * Store glTF extras (if present) in BJS objects' metadata
  66825. */
  66826. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66827. /** The name of this extension. */
  66828. readonly name: string;
  66829. /** Defines whether this extension is enabled. */
  66830. enabled: boolean;
  66831. private _loader;
  66832. private _assignExtras;
  66833. /** @hidden */
  66834. constructor(loader: GLTFLoader);
  66835. /** @hidden */
  66836. dispose(): void;
  66837. /** @hidden */
  66838. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66839. /** @hidden */
  66840. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66841. /** @hidden */
  66842. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66843. }
  66844. }
  66845. declare module BABYLON {
  66846. /**
  66847. * Class reading and parsing the MTL file bundled with the obj file.
  66848. */
  66849. export class MTLFileLoader {
  66850. /**
  66851. * All material loaded from the mtl will be set here
  66852. */
  66853. materials: StandardMaterial[];
  66854. /**
  66855. * This function will read the mtl file and create each material described inside
  66856. * This function could be improve by adding :
  66857. * -some component missing (Ni, Tf...)
  66858. * -including the specific options available
  66859. *
  66860. * @param scene defines the scene the material will be created in
  66861. * @param data defines the mtl data to parse
  66862. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66863. */
  66864. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66865. /**
  66866. * Gets the texture for the material.
  66867. *
  66868. * If the material is imported from input file,
  66869. * We sanitize the url to ensure it takes the textre from aside the material.
  66870. *
  66871. * @param rootUrl The root url to load from
  66872. * @param value The value stored in the mtl
  66873. * @return The Texture
  66874. */
  66875. private static _getTexture;
  66876. }
  66877. /**
  66878. * Options for loading OBJ/MTL files
  66879. */
  66880. type MeshLoadOptions = {
  66881. /**
  66882. * Defines if UVs are optimized by default during load.
  66883. */
  66884. OptimizeWithUV: boolean;
  66885. /**
  66886. * Defines custom scaling of UV coordinates of loaded meshes.
  66887. */
  66888. UVScaling: Vector2;
  66889. /**
  66890. * Invert model on y-axis (does a model scaling inversion)
  66891. */
  66892. InvertY: boolean;
  66893. /**
  66894. * Invert Y-Axis of referenced textures on load
  66895. */
  66896. InvertTextureY: boolean;
  66897. /**
  66898. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66899. */
  66900. ImportVertexColors: boolean;
  66901. /**
  66902. * Compute the normals for the model, even if normals are present in the file.
  66903. */
  66904. ComputeNormals: boolean;
  66905. /**
  66906. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66907. */
  66908. SkipMaterials: boolean;
  66909. /**
  66910. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66911. */
  66912. MaterialLoadingFailsSilently: boolean;
  66913. };
  66914. /**
  66915. * OBJ file type loader.
  66916. * This is a babylon scene loader plugin.
  66917. */
  66918. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66919. /**
  66920. * Defines if UVs are optimized by default during load.
  66921. */
  66922. static OPTIMIZE_WITH_UV: boolean;
  66923. /**
  66924. * Invert model on y-axis (does a model scaling inversion)
  66925. */
  66926. static INVERT_Y: boolean;
  66927. /**
  66928. * Invert Y-Axis of referenced textures on load
  66929. */
  66930. static INVERT_TEXTURE_Y: boolean;
  66931. /**
  66932. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66933. */
  66934. static IMPORT_VERTEX_COLORS: boolean;
  66935. /**
  66936. * Compute the normals for the model, even if normals are present in the file.
  66937. */
  66938. static COMPUTE_NORMALS: boolean;
  66939. /**
  66940. * Defines custom scaling of UV coordinates of loaded meshes.
  66941. */
  66942. static UV_SCALING: Vector2;
  66943. /**
  66944. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66945. */
  66946. static SKIP_MATERIALS: boolean;
  66947. /**
  66948. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66949. *
  66950. * Defaults to true for backwards compatibility.
  66951. */
  66952. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  66953. /**
  66954. * Defines the name of the plugin.
  66955. */
  66956. name: string;
  66957. /**
  66958. * Defines the extension the plugin is able to load.
  66959. */
  66960. extensions: string;
  66961. /** @hidden */
  66962. obj: RegExp;
  66963. /** @hidden */
  66964. group: RegExp;
  66965. /** @hidden */
  66966. mtllib: RegExp;
  66967. /** @hidden */
  66968. usemtl: RegExp;
  66969. /** @hidden */
  66970. smooth: RegExp;
  66971. /** @hidden */
  66972. vertexPattern: RegExp;
  66973. /** @hidden */
  66974. normalPattern: RegExp;
  66975. /** @hidden */
  66976. uvPattern: RegExp;
  66977. /** @hidden */
  66978. facePattern1: RegExp;
  66979. /** @hidden */
  66980. facePattern2: RegExp;
  66981. /** @hidden */
  66982. facePattern3: RegExp;
  66983. /** @hidden */
  66984. facePattern4: RegExp;
  66985. /** @hidden */
  66986. facePattern5: RegExp;
  66987. private _meshLoadOptions;
  66988. /**
  66989. * Creates loader for .OBJ files
  66990. *
  66991. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  66992. */
  66993. constructor(meshLoadOptions?: MeshLoadOptions);
  66994. private static readonly currentMeshLoadOptions;
  66995. /**
  66996. * Calls synchronously the MTL file attached to this obj.
  66997. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  66998. * Without this function materials are not displayed in the first frame (but displayed after).
  66999. * In consequence it is impossible to get material information in your HTML file
  67000. *
  67001. * @param url The URL of the MTL file
  67002. * @param rootUrl
  67003. * @param onSuccess Callback function to be called when the MTL file is loaded
  67004. * @private
  67005. */
  67006. private _loadMTL;
  67007. /**
  67008. * Instantiates a OBJ file loader plugin.
  67009. * @returns the created plugin
  67010. */
  67011. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67012. /**
  67013. * If the data string can be loaded directly.
  67014. *
  67015. * @param data string containing the file data
  67016. * @returns if the data can be loaded directly
  67017. */
  67018. canDirectLoad(data: string): boolean;
  67019. /**
  67020. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67021. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67022. * @param scene the scene the meshes should be added to
  67023. * @param data the OBJ data to load
  67024. * @param rootUrl root url to load from
  67025. * @param onProgress event that fires when loading progress has occured
  67026. * @param fileName Defines the name of the file to load
  67027. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67028. */
  67029. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67030. meshes: AbstractMesh[];
  67031. particleSystems: IParticleSystem[];
  67032. skeletons: Skeleton[];
  67033. animationGroups: AnimationGroup[];
  67034. }>;
  67035. /**
  67036. * Imports all objects from the loaded OBJ data and adds them to the scene
  67037. * @param scene the scene the objects should be added to
  67038. * @param data the OBJ data to load
  67039. * @param rootUrl root url to load from
  67040. * @param onProgress event that fires when loading progress has occured
  67041. * @param fileName Defines the name of the file to load
  67042. * @returns a promise which completes when objects have been loaded to the scene
  67043. */
  67044. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67045. /**
  67046. * Load into an asset container.
  67047. * @param scene The scene to load into
  67048. * @param data The data to import
  67049. * @param rootUrl The root url for scene and resources
  67050. * @param onProgress The callback when the load progresses
  67051. * @param fileName Defines the name of the file to load
  67052. * @returns The loaded asset container
  67053. */
  67054. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67055. /**
  67056. * Read the OBJ file and create an Array of meshes.
  67057. * Each mesh contains all information given by the OBJ and the MTL file.
  67058. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67059. *
  67060. * @param meshesNames
  67061. * @param scene Scene The scene where are displayed the data
  67062. * @param data String The content of the obj file
  67063. * @param rootUrl String The path to the folder
  67064. * @returns Array<AbstractMesh>
  67065. * @private
  67066. */
  67067. private _parseSolid;
  67068. }
  67069. }
  67070. declare module BABYLON {
  67071. /**
  67072. * STL file type loader.
  67073. * This is a babylon scene loader plugin.
  67074. */
  67075. export class STLFileLoader implements ISceneLoaderPlugin {
  67076. /** @hidden */
  67077. solidPattern: RegExp;
  67078. /** @hidden */
  67079. facetsPattern: RegExp;
  67080. /** @hidden */
  67081. normalPattern: RegExp;
  67082. /** @hidden */
  67083. vertexPattern: RegExp;
  67084. /**
  67085. * Defines the name of the plugin.
  67086. */
  67087. name: string;
  67088. /**
  67089. * Defines the extensions the stl loader is able to load.
  67090. * force data to come in as an ArrayBuffer
  67091. * we'll convert to string if it looks like it's an ASCII .stl
  67092. */
  67093. extensions: ISceneLoaderPluginExtensions;
  67094. /**
  67095. * Import meshes into a scene.
  67096. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67097. * @param scene The scene to import into
  67098. * @param data The data to import
  67099. * @param rootUrl The root url for scene and resources
  67100. * @param meshes The meshes array to import into
  67101. * @param particleSystems The particle systems array to import into
  67102. * @param skeletons The skeletons array to import into
  67103. * @param onError The callback when import fails
  67104. * @returns True if successful or false otherwise
  67105. */
  67106. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67107. /**
  67108. * Load into a scene.
  67109. * @param scene The scene to load into
  67110. * @param data The data to import
  67111. * @param rootUrl The root url for scene and resources
  67112. * @param onError The callback when import fails
  67113. * @returns true if successful or false otherwise
  67114. */
  67115. load(scene: Scene, data: any, rootUrl: string): boolean;
  67116. /**
  67117. * Load into an asset container.
  67118. * @param scene The scene to load into
  67119. * @param data The data to import
  67120. * @param rootUrl The root url for scene and resources
  67121. * @param onError The callback when import fails
  67122. * @returns The loaded asset container
  67123. */
  67124. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67125. private _isBinary;
  67126. private _parseBinary;
  67127. private _parseASCII;
  67128. }
  67129. }
  67130. declare module BABYLON {
  67131. /**
  67132. * Class for generating OBJ data from a Babylon scene.
  67133. */
  67134. export class OBJExport {
  67135. /**
  67136. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67137. * @param mesh defines the list of meshes to serialize
  67138. * @param materials defines if materials should be exported
  67139. * @param matlibname defines the name of the associated mtl file
  67140. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67141. * @returns the OBJ content
  67142. */
  67143. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67144. /**
  67145. * Exports the material(s) of a mesh in .MTL file format (text)
  67146. * @param mesh defines the mesh to extract the material from
  67147. * @returns the mtl content
  67148. */
  67149. static MTL(mesh: Mesh): string;
  67150. }
  67151. }
  67152. declare module BABYLON {
  67153. /** @hidden */
  67154. export var __IGLTFExporterExtension: number;
  67155. /**
  67156. * Interface for extending the exporter
  67157. * @hidden
  67158. */
  67159. export interface IGLTFExporterExtension {
  67160. /**
  67161. * The name of this extension
  67162. */
  67163. readonly name: string;
  67164. /**
  67165. * Defines whether this extension is enabled
  67166. */
  67167. enabled: boolean;
  67168. /**
  67169. * Defines whether this extension is required
  67170. */
  67171. required: boolean;
  67172. }
  67173. }
  67174. declare module BABYLON.GLTF2.Exporter {
  67175. /** @hidden */
  67176. export var __IGLTFExporterExtensionV2: number;
  67177. /**
  67178. * Interface for a glTF exporter extension
  67179. * @hidden
  67180. */
  67181. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67182. /**
  67183. * Define this method to modify the default behavior before exporting a texture
  67184. * @param context The context when loading the asset
  67185. * @param babylonTexture The glTF texture info property
  67186. * @param mimeType The mime-type of the generated image
  67187. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67188. */
  67189. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67190. /**
  67191. * Define this method to modify the default behavior when exporting texture info
  67192. * @param context The context when loading the asset
  67193. * @param meshPrimitive glTF mesh primitive
  67194. * @param babylonSubMesh Babylon submesh
  67195. * @param binaryWriter glTF serializer binary writer instance
  67196. * @returns nullable IMeshPrimitive promise
  67197. */
  67198. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67199. /**
  67200. * Define this method to modify the default behavior when exporting a node
  67201. * @param context The context when exporting the node
  67202. * @param node glTF node
  67203. * @param babylonNode BabylonJS node
  67204. * @returns nullable INode promise
  67205. */
  67206. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67207. /**
  67208. * Called after the exporter state changes to EXPORTING
  67209. */
  67210. onExporting?(): void;
  67211. }
  67212. }
  67213. declare module BABYLON.GLTF2.Exporter {
  67214. /**
  67215. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67216. * @hidden
  67217. */
  67218. export class _GLTFMaterialExporter {
  67219. /**
  67220. * Represents the dielectric specular values for R, G and B
  67221. */
  67222. private static readonly _DielectricSpecular;
  67223. /**
  67224. * Allows the maximum specular power to be defined for material calculations
  67225. */
  67226. private static readonly _MaxSpecularPower;
  67227. /**
  67228. * Mapping to store textures
  67229. */
  67230. private _textureMap;
  67231. /**
  67232. * Numeric tolerance value
  67233. */
  67234. private static readonly _Epsilon;
  67235. /**
  67236. * Reference to the glTF Exporter
  67237. */
  67238. private _exporter;
  67239. constructor(exporter: _Exporter);
  67240. /**
  67241. * Specifies if two colors are approximately equal in value
  67242. * @param color1 first color to compare to
  67243. * @param color2 second color to compare to
  67244. * @param epsilon threshold value
  67245. */
  67246. private static FuzzyEquals;
  67247. /**
  67248. * Gets the materials from a Babylon scene and converts them to glTF materials
  67249. * @param scene babylonjs scene
  67250. * @param mimeType texture mime type
  67251. * @param images array of images
  67252. * @param textures array of textures
  67253. * @param materials array of materials
  67254. * @param imageData mapping of texture names to base64 textures
  67255. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67256. */
  67257. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67258. /**
  67259. * Makes a copy of the glTF material without the texture parameters
  67260. * @param originalMaterial original glTF material
  67261. * @returns glTF material without texture parameters
  67262. */
  67263. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67264. /**
  67265. * Specifies if the material has any texture parameters present
  67266. * @param material glTF Material
  67267. * @returns boolean specifying if texture parameters are present
  67268. */
  67269. _hasTexturesPresent(material: IMaterial): boolean;
  67270. /**
  67271. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67272. * @param babylonStandardMaterial
  67273. * @returns glTF Metallic Roughness Material representation
  67274. */
  67275. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67276. /**
  67277. * Computes the metallic factor
  67278. * @param diffuse diffused value
  67279. * @param specular specular value
  67280. * @param oneMinusSpecularStrength one minus the specular strength
  67281. * @returns metallic value
  67282. */
  67283. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67284. /**
  67285. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67286. * @param glTFMaterial glTF material
  67287. * @param babylonMaterial Babylon material
  67288. */
  67289. private static _SetAlphaMode;
  67290. /**
  67291. * Converts a Babylon Standard Material to a glTF Material
  67292. * @param babylonStandardMaterial BJS Standard Material
  67293. * @param mimeType mime type to use for the textures
  67294. * @param images array of glTF image interfaces
  67295. * @param textures array of glTF texture interfaces
  67296. * @param materials array of glTF material interfaces
  67297. * @param imageData map of image file name to data
  67298. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67299. */
  67300. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67301. /**
  67302. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67303. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67304. * @param mimeType mime type to use for the textures
  67305. * @param images array of glTF image interfaces
  67306. * @param textures array of glTF texture interfaces
  67307. * @param materials array of glTF material interfaces
  67308. * @param imageData map of image file name to data
  67309. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67310. */
  67311. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67312. /**
  67313. * Converts an image typed array buffer to a base64 image
  67314. * @param buffer typed array buffer
  67315. * @param width width of the image
  67316. * @param height height of the image
  67317. * @param mimeType mimetype of the image
  67318. * @returns base64 image string
  67319. */
  67320. private _createBase64FromCanvasAsync;
  67321. /**
  67322. * Generates a white texture based on the specified width and height
  67323. * @param width width of the texture in pixels
  67324. * @param height height of the texture in pixels
  67325. * @param scene babylonjs scene
  67326. * @returns white texture
  67327. */
  67328. private _createWhiteTexture;
  67329. /**
  67330. * 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
  67331. * @param texture1 first texture to resize
  67332. * @param texture2 second texture to resize
  67333. * @param scene babylonjs scene
  67334. * @returns resized textures or null
  67335. */
  67336. private _resizeTexturesToSameDimensions;
  67337. /**
  67338. * Converts an array of pixels to a Float32Array
  67339. * Throws an error if the pixel format is not supported
  67340. * @param pixels - array buffer containing pixel values
  67341. * @returns Float32 of pixels
  67342. */
  67343. private _convertPixelArrayToFloat32;
  67344. /**
  67345. * Convert Specular Glossiness Textures to Metallic Roughness
  67346. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67347. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67348. * @param diffuseTexture texture used to store diffuse information
  67349. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67350. * @param factors specular glossiness material factors
  67351. * @param mimeType the mime type to use for the texture
  67352. * @returns pbr metallic roughness interface or null
  67353. */
  67354. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67355. /**
  67356. * Converts specular glossiness material properties to metallic roughness
  67357. * @param specularGlossiness interface with specular glossiness material properties
  67358. * @returns interface with metallic roughness material properties
  67359. */
  67360. private _convertSpecularGlossinessToMetallicRoughness;
  67361. /**
  67362. * Calculates the surface reflectance, independent of lighting conditions
  67363. * @param color Color source to calculate brightness from
  67364. * @returns number representing the perceived brightness, or zero if color is undefined
  67365. */
  67366. private _getPerceivedBrightness;
  67367. /**
  67368. * Returns the maximum color component value
  67369. * @param color
  67370. * @returns maximum color component value, or zero if color is null or undefined
  67371. */
  67372. private _getMaxComponent;
  67373. /**
  67374. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67375. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67376. * @param mimeType mime type to use for the textures
  67377. * @param images array of glTF image interfaces
  67378. * @param textures array of glTF texture interfaces
  67379. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67380. * @param imageData map of image file name to data
  67381. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67382. * @returns glTF PBR Metallic Roughness factors
  67383. */
  67384. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67385. private _getGLTFTextureSampler;
  67386. private _getGLTFTextureWrapMode;
  67387. private _getGLTFTextureWrapModesSampler;
  67388. /**
  67389. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67390. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67391. * @param mimeType mime type to use for the textures
  67392. * @param images array of glTF image interfaces
  67393. * @param textures array of glTF texture interfaces
  67394. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67395. * @param imageData map of image file name to data
  67396. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67397. * @returns glTF PBR Metallic Roughness factors
  67398. */
  67399. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67400. /**
  67401. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67402. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67403. * @param mimeType mime type to use for the textures
  67404. * @param images array of glTF image interfaces
  67405. * @param textures array of glTF texture interfaces
  67406. * @param materials array of glTF material interfaces
  67407. * @param imageData map of image file name to data
  67408. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67409. */
  67410. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67411. private setMetallicRoughnessPbrMaterial;
  67412. private getPixelsFromTexture;
  67413. /**
  67414. * Extracts a texture from a Babylon texture into file data and glTF data
  67415. * @param babylonTexture Babylon texture to extract
  67416. * @param mimeType Mime Type of the babylonTexture
  67417. * @return glTF texture info, or null if the texture format is not supported
  67418. */
  67419. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67420. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67421. /**
  67422. * Builds a texture from base64 string
  67423. * @param base64Texture base64 texture string
  67424. * @param baseTextureName Name to use for the texture
  67425. * @param mimeType image mime type for the texture
  67426. * @param images array of images
  67427. * @param textures array of textures
  67428. * @param imageData map of image data
  67429. * @returns glTF texture info, or null if the texture format is not supported
  67430. */
  67431. private _getTextureInfoFromBase64;
  67432. }
  67433. }
  67434. declare module BABYLON {
  67435. /**
  67436. * Class for holding and downloading glTF file data
  67437. */
  67438. export class GLTFData {
  67439. /**
  67440. * Object which contains the file name as the key and its data as the value
  67441. */
  67442. glTFFiles: {
  67443. [fileName: string]: string | Blob;
  67444. };
  67445. /**
  67446. * Initializes the glTF file object
  67447. */
  67448. constructor();
  67449. /**
  67450. * Downloads the glTF data as files based on their names and data
  67451. */
  67452. downloadFiles(): void;
  67453. }
  67454. }
  67455. declare module BABYLON {
  67456. /**
  67457. * Holds a collection of exporter options and parameters
  67458. */
  67459. export interface IExportOptions {
  67460. /**
  67461. * Function which indicates whether a babylon node should be exported or not
  67462. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67463. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67464. */
  67465. shouldExportNode?(node: Node): boolean;
  67466. /**
  67467. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67468. * @param metadata source metadata to read from
  67469. * @returns the data to store to glTF node extras
  67470. */
  67471. metadataSelector?(metadata: any): any;
  67472. /**
  67473. * The sample rate to bake animation curves
  67474. */
  67475. animationSampleRate?: number;
  67476. /**
  67477. * Begin serialization without waiting for the scene to be ready
  67478. */
  67479. exportWithoutWaitingForScene?: boolean;
  67480. }
  67481. /**
  67482. * Class for generating glTF data from a Babylon scene.
  67483. */
  67484. export class GLTF2Export {
  67485. /**
  67486. * Exports the geometry of the scene to .gltf file format asynchronously
  67487. * @param scene Babylon scene with scene hierarchy information
  67488. * @param filePrefix File prefix to use when generating the glTF file
  67489. * @param options Exporter options
  67490. * @returns Returns an object with a .gltf file and associates texture names
  67491. * as keys and their data and paths as values
  67492. */
  67493. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67494. private static _PreExportAsync;
  67495. private static _PostExportAsync;
  67496. /**
  67497. * Exports the geometry of the scene to .glb file format asychronously
  67498. * @param scene Babylon scene with scene hierarchy information
  67499. * @param filePrefix File prefix to use when generating glb file
  67500. * @param options Exporter options
  67501. * @returns Returns an object with a .glb filename as key and data as value
  67502. */
  67503. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67504. }
  67505. }
  67506. declare module BABYLON.GLTF2.Exporter {
  67507. /**
  67508. * @hidden
  67509. */
  67510. export class _GLTFUtilities {
  67511. /**
  67512. * Creates a buffer view based on the supplied arguments
  67513. * @param bufferIndex index value of the specified buffer
  67514. * @param byteOffset byte offset value
  67515. * @param byteLength byte length of the bufferView
  67516. * @param byteStride byte distance between conequential elements
  67517. * @param name name of the buffer view
  67518. * @returns bufferView for glTF
  67519. */
  67520. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67521. /**
  67522. * Creates an accessor based on the supplied arguments
  67523. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67524. * @param name The name of the accessor
  67525. * @param type The type of the accessor
  67526. * @param componentType The datatype of components in the attribute
  67527. * @param count The number of attributes referenced by this accessor
  67528. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67529. * @param min Minimum value of each component in this attribute
  67530. * @param max Maximum value of each component in this attribute
  67531. * @returns accessor for glTF
  67532. */
  67533. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67534. /**
  67535. * Calculates the minimum and maximum values of an array of position floats
  67536. * @param positions Positions array of a mesh
  67537. * @param vertexStart Starting vertex offset to calculate min and max values
  67538. * @param vertexCount Number of vertices to check for min and max values
  67539. * @returns min number array and max number array
  67540. */
  67541. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67542. min: number[];
  67543. max: number[];
  67544. };
  67545. /**
  67546. * Converts a new right-handed Vector3
  67547. * @param vector vector3 array
  67548. * @returns right-handed Vector3
  67549. */
  67550. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67551. /**
  67552. * Converts a Vector3 to right-handed
  67553. * @param vector Vector3 to convert to right-handed
  67554. */
  67555. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67556. /**
  67557. * Converts a three element number array to right-handed
  67558. * @param vector number array to convert to right-handed
  67559. */
  67560. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67561. /**
  67562. * Converts a new right-handed Vector3
  67563. * @param vector vector3 array
  67564. * @returns right-handed Vector3
  67565. */
  67566. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67567. /**
  67568. * Converts a Vector3 to right-handed
  67569. * @param vector Vector3 to convert to right-handed
  67570. */
  67571. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67572. /**
  67573. * Converts a three element number array to right-handed
  67574. * @param vector number array to convert to right-handed
  67575. */
  67576. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67577. /**
  67578. * Converts a Vector4 to right-handed
  67579. * @param vector Vector4 to convert to right-handed
  67580. */
  67581. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67582. /**
  67583. * Converts a Vector4 to right-handed
  67584. * @param vector Vector4 to convert to right-handed
  67585. */
  67586. static _GetRightHandedArray4FromRef(vector: number[]): void;
  67587. /**
  67588. * Converts a Quaternion to right-handed
  67589. * @param quaternion Source quaternion to convert to right-handed
  67590. */
  67591. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67592. /**
  67593. * Converts a Quaternion to right-handed
  67594. * @param quaternion Source quaternion to convert to right-handed
  67595. */
  67596. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  67597. static _NormalizeTangentFromRef(tangent: Vector4): void;
  67598. }
  67599. }
  67600. declare module BABYLON.GLTF2.Exporter {
  67601. /**
  67602. * Converts Babylon Scene into glTF 2.0.
  67603. * @hidden
  67604. */
  67605. export class _Exporter {
  67606. /**
  67607. * Stores the glTF to export
  67608. */
  67609. _glTF: IGLTF;
  67610. /**
  67611. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67612. */
  67613. _bufferViews: IBufferView[];
  67614. /**
  67615. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67616. */
  67617. _accessors: IAccessor[];
  67618. /**
  67619. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67620. */
  67621. private _nodes;
  67622. /**
  67623. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67624. */
  67625. private _scenes;
  67626. /**
  67627. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67628. */
  67629. private _meshes;
  67630. /**
  67631. * Stores all the generated material information, which represents the appearance of each primitive
  67632. */
  67633. _materials: IMaterial[];
  67634. _materialMap: {
  67635. [materialID: number]: number;
  67636. };
  67637. /**
  67638. * Stores all the generated texture information, which is referenced by glTF materials
  67639. */
  67640. _textures: ITexture[];
  67641. /**
  67642. * Stores all the generated image information, which is referenced by glTF textures
  67643. */
  67644. _images: IImage[];
  67645. /**
  67646. * Stores all the texture samplers
  67647. */
  67648. _samplers: ISampler[];
  67649. /**
  67650. * Stores all the generated animation samplers, which is referenced by glTF animations
  67651. */
  67652. /**
  67653. * Stores the animations for glTF models
  67654. */
  67655. private _animations;
  67656. /**
  67657. * Stores the total amount of bytes stored in the glTF buffer
  67658. */
  67659. private _totalByteLength;
  67660. /**
  67661. * Stores a reference to the Babylon scene containing the source geometry and material information
  67662. */
  67663. _babylonScene: Scene;
  67664. /**
  67665. * Stores a map of the image data, where the key is the file name and the value
  67666. * is the image data
  67667. */
  67668. _imageData: {
  67669. [fileName: string]: {
  67670. data: Uint8Array;
  67671. mimeType: ImageMimeType;
  67672. };
  67673. };
  67674. /**
  67675. * Stores a map of the unique id of a node to its index in the node array
  67676. */
  67677. private _nodeMap;
  67678. /**
  67679. * Specifies if the Babylon scene should be converted to right-handed on export
  67680. */
  67681. _convertToRightHandedSystem: boolean;
  67682. /**
  67683. * Baked animation sample rate
  67684. */
  67685. private _animationSampleRate;
  67686. private _options;
  67687. private _localEngine;
  67688. _glTFMaterialExporter: _GLTFMaterialExporter;
  67689. private _extensions;
  67690. private static _ExtensionNames;
  67691. private static _ExtensionFactories;
  67692. private _applyExtensions;
  67693. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  67694. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67695. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67696. private _forEachExtensions;
  67697. private _extensionsOnExporting;
  67698. /**
  67699. * Load glTF serializer extensions
  67700. */
  67701. private _loadExtensions;
  67702. /**
  67703. * Creates a glTF Exporter instance, which can accept optional exporter options
  67704. * @param babylonScene Babylon scene object
  67705. * @param options Options to modify the behavior of the exporter
  67706. */
  67707. constructor(babylonScene: Scene, options?: IExportOptions);
  67708. /**
  67709. * Registers a glTF exporter extension
  67710. * @param name Name of the extension to export
  67711. * @param factory The factory function that creates the exporter extension
  67712. */
  67713. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67714. /**
  67715. * Un-registers an exporter extension
  67716. * @param name The name fo the exporter extension
  67717. * @returns A boolean indicating whether the extension has been un-registered
  67718. */
  67719. static UnregisterExtension(name: string): boolean;
  67720. /**
  67721. * Lazy load a local engine with premultiplied alpha set to false
  67722. */
  67723. _getLocalEngine(): Engine;
  67724. private reorderIndicesBasedOnPrimitiveMode;
  67725. /**
  67726. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67727. * clock-wise during export to glTF
  67728. * @param submesh BabylonJS submesh
  67729. * @param primitiveMode Primitive mode of the mesh
  67730. * @param sideOrientation the winding order of the submesh
  67731. * @param vertexBufferKind The type of vertex attribute
  67732. * @param meshAttributeArray The vertex attribute data
  67733. * @param byteOffset The offset to the binary data
  67734. * @param binaryWriter The binary data for the glTF file
  67735. */
  67736. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  67737. /**
  67738. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  67739. * clock-wise during export to glTF
  67740. * @param submesh BabylonJS submesh
  67741. * @param primitiveMode Primitive mode of the mesh
  67742. * @param sideOrientation the winding order of the submesh
  67743. * @param vertexBufferKind The type of vertex attribute
  67744. * @param meshAttributeArray The vertex attribute data
  67745. * @param byteOffset The offset to the binary data
  67746. * @param binaryWriter The binary data for the glTF file
  67747. */
  67748. private reorderTriangleFillMode;
  67749. /**
  67750. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  67751. * clock-wise during export to glTF
  67752. * @param submesh BabylonJS submesh
  67753. * @param primitiveMode Primitive mode of the mesh
  67754. * @param sideOrientation the winding order of the submesh
  67755. * @param vertexBufferKind The type of vertex attribute
  67756. * @param meshAttributeArray The vertex attribute data
  67757. * @param byteOffset The offset to the binary data
  67758. * @param binaryWriter The binary data for the glTF file
  67759. */
  67760. private reorderTriangleStripDrawMode;
  67761. /**
  67762. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  67763. * clock-wise during export to glTF
  67764. * @param submesh BabylonJS submesh
  67765. * @param primitiveMode Primitive mode of the mesh
  67766. * @param sideOrientation the winding order of the submesh
  67767. * @param vertexBufferKind The type of vertex attribute
  67768. * @param meshAttributeArray The vertex attribute data
  67769. * @param byteOffset The offset to the binary data
  67770. * @param binaryWriter The binary data for the glTF file
  67771. */
  67772. private reorderTriangleFanMode;
  67773. /**
  67774. * Writes the vertex attribute data to binary
  67775. * @param vertices The vertices to write to the binary writer
  67776. * @param byteOffset The offset into the binary writer to overwrite binary data
  67777. * @param vertexAttributeKind The vertex attribute type
  67778. * @param meshAttributeArray The vertex attribute data
  67779. * @param binaryWriter The writer containing the binary data
  67780. */
  67781. private writeVertexAttributeData;
  67782. /**
  67783. * Writes mesh attribute data to a data buffer
  67784. * Returns the bytelength of the data
  67785. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67786. * @param meshAttributeArray Array containing the attribute data
  67787. * @param binaryWriter The buffer to write the binary data to
  67788. * @param indices Used to specify the order of the vertex data
  67789. */
  67790. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67791. /**
  67792. * Generates glTF json data
  67793. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67794. * @param glTFPrefix Text to use when prefixing a glTF file
  67795. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67796. * @returns json data as string
  67797. */
  67798. private generateJSON;
  67799. /**
  67800. * Generates data for .gltf and .bin files based on the glTF prefix string
  67801. * @param glTFPrefix Text to use when prefixing a glTF file
  67802. * @returns GLTFData with glTF file data
  67803. */
  67804. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67805. /**
  67806. * Creates a binary buffer for glTF
  67807. * @returns array buffer for binary data
  67808. */
  67809. private _generateBinaryAsync;
  67810. /**
  67811. * Pads the number to a multiple of 4
  67812. * @param num number to pad
  67813. * @returns padded number
  67814. */
  67815. private _getPadding;
  67816. /**
  67817. * Generates a glb file from the json and binary data
  67818. * Returns an object with the glb file name as the key and data as the value
  67819. * @param glTFPrefix
  67820. * @returns object with glb filename as key and data as value
  67821. */
  67822. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67823. /**
  67824. * Sets the TRS for each node
  67825. * @param node glTF Node for storing the transformation data
  67826. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67827. */
  67828. private setNodeTransformation;
  67829. private getVertexBufferFromMesh;
  67830. /**
  67831. * Creates a bufferview based on the vertices type for the Babylon mesh
  67832. * @param kind Indicates the type of vertices data
  67833. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67834. * @param binaryWriter The buffer to write the bufferview data to
  67835. */
  67836. private createBufferViewKind;
  67837. /**
  67838. * The primitive mode of the Babylon mesh
  67839. * @param babylonMesh The BabylonJS mesh
  67840. */
  67841. private getMeshPrimitiveMode;
  67842. /**
  67843. * Sets the primitive mode of the glTF mesh primitive
  67844. * @param meshPrimitive glTF mesh primitive
  67845. * @param primitiveMode The primitive mode
  67846. */
  67847. private setPrimitiveMode;
  67848. /**
  67849. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67850. * @param meshPrimitive glTF mesh primitive
  67851. * @param attributeKind vertex attribute
  67852. * @returns boolean specifying if uv coordinates are present
  67853. */
  67854. private setAttributeKind;
  67855. /**
  67856. * Sets data for the primitive attributes of each submesh
  67857. * @param mesh glTF Mesh object to store the primitive attribute information
  67858. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67859. * @param binaryWriter Buffer to write the attribute data to
  67860. */
  67861. private setPrimitiveAttributesAsync;
  67862. /**
  67863. * Creates a glTF scene based on the array of meshes
  67864. * Returns the the total byte offset
  67865. * @param babylonScene Babylon scene to get the mesh data from
  67866. * @param binaryWriter Buffer to write binary data to
  67867. */
  67868. private createSceneAsync;
  67869. /**
  67870. * Creates a mapping of Node unique id to node index and handles animations
  67871. * @param babylonScene Babylon Scene
  67872. * @param nodes Babylon transform nodes
  67873. * @param binaryWriter Buffer to write binary data to
  67874. * @returns Node mapping of unique id to index
  67875. */
  67876. private createNodeMapAndAnimationsAsync;
  67877. /**
  67878. * Creates a glTF node from a Babylon mesh
  67879. * @param babylonMesh Source Babylon mesh
  67880. * @param binaryWriter Buffer for storing geometry data
  67881. * @returns glTF node
  67882. */
  67883. private createNodeAsync;
  67884. }
  67885. /**
  67886. * @hidden
  67887. *
  67888. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67889. */
  67890. export class _BinaryWriter {
  67891. /**
  67892. * Array buffer which stores all binary data
  67893. */
  67894. private _arrayBuffer;
  67895. /**
  67896. * View of the array buffer
  67897. */
  67898. private _dataView;
  67899. /**
  67900. * byte offset of data in array buffer
  67901. */
  67902. private _byteOffset;
  67903. /**
  67904. * Initialize binary writer with an initial byte length
  67905. * @param byteLength Initial byte length of the array buffer
  67906. */
  67907. constructor(byteLength: number);
  67908. /**
  67909. * Resize the array buffer to the specified byte length
  67910. * @param byteLength
  67911. */
  67912. private resizeBuffer;
  67913. /**
  67914. * Get an array buffer with the length of the byte offset
  67915. * @returns ArrayBuffer resized to the byte offset
  67916. */
  67917. getArrayBuffer(): ArrayBuffer;
  67918. /**
  67919. * Get the byte offset of the array buffer
  67920. * @returns byte offset
  67921. */
  67922. getByteOffset(): number;
  67923. /**
  67924. * Stores an UInt8 in the array buffer
  67925. * @param entry
  67926. * @param byteOffset If defined, specifies where to set the value as an offset.
  67927. */
  67928. setUInt8(entry: number, byteOffset?: number): void;
  67929. /**
  67930. * Gets an UInt32 in the array buffer
  67931. * @param entry
  67932. * @param byteOffset If defined, specifies where to set the value as an offset.
  67933. */
  67934. getUInt32(byteOffset: number): number;
  67935. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67936. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67937. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67938. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67939. /**
  67940. * Stores a Float32 in the array buffer
  67941. * @param entry
  67942. */
  67943. setFloat32(entry: number, byteOffset?: number): void;
  67944. /**
  67945. * Stores an UInt32 in the array buffer
  67946. * @param entry
  67947. * @param byteOffset If defined, specifies where to set the value as an offset.
  67948. */
  67949. setUInt32(entry: number, byteOffset?: number): void;
  67950. }
  67951. }
  67952. declare module BABYLON.GLTF2.Exporter {
  67953. /**
  67954. * @hidden
  67955. * Interface to store animation data.
  67956. */
  67957. export interface _IAnimationData {
  67958. /**
  67959. * Keyframe data.
  67960. */
  67961. inputs: number[];
  67962. /**
  67963. * Value data.
  67964. */
  67965. outputs: number[][];
  67966. /**
  67967. * Animation interpolation data.
  67968. */
  67969. samplerInterpolation: AnimationSamplerInterpolation;
  67970. /**
  67971. * Minimum keyframe value.
  67972. */
  67973. inputsMin: number;
  67974. /**
  67975. * Maximum keyframe value.
  67976. */
  67977. inputsMax: number;
  67978. }
  67979. /**
  67980. * @hidden
  67981. */
  67982. export interface _IAnimationInfo {
  67983. /**
  67984. * The target channel for the animation
  67985. */
  67986. animationChannelTargetPath: AnimationChannelTargetPath;
  67987. /**
  67988. * The glTF accessor type for the data.
  67989. */
  67990. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  67991. /**
  67992. * Specifies if quaternions should be used.
  67993. */
  67994. useQuaternion: boolean;
  67995. }
  67996. /**
  67997. * @hidden
  67998. * Utility class for generating glTF animation data from BabylonJS.
  67999. */
  68000. export class _GLTFAnimation {
  68001. /**
  68002. * @ignore
  68003. *
  68004. * Creates glTF channel animation from BabylonJS animation.
  68005. * @param babylonTransformNode - BabylonJS mesh.
  68006. * @param animation - animation.
  68007. * @param animationChannelTargetPath - The target animation channel.
  68008. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68009. * @param useQuaternion - Specifies if quaternions are used.
  68010. * @returns nullable IAnimationData
  68011. */
  68012. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68013. private static _DeduceAnimationInfo;
  68014. /**
  68015. * @ignore
  68016. * Create node animations from the transform node animations
  68017. * @param babylonNode
  68018. * @param runtimeGLTFAnimation
  68019. * @param idleGLTFAnimations
  68020. * @param nodeMap
  68021. * @param nodes
  68022. * @param binaryWriter
  68023. * @param bufferViews
  68024. * @param accessors
  68025. * @param convertToRightHandedSystem
  68026. */
  68027. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68028. [key: number]: number;
  68029. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68030. /**
  68031. * @ignore
  68032. * Create node animations from the animation groups
  68033. * @param babylonScene
  68034. * @param glTFAnimations
  68035. * @param nodeMap
  68036. * @param nodes
  68037. * @param binaryWriter
  68038. * @param bufferViews
  68039. * @param accessors
  68040. * @param convertToRightHandedSystem
  68041. */
  68042. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68043. [key: number]: number;
  68044. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68045. private static AddAnimation;
  68046. /**
  68047. * Create a baked animation
  68048. * @param babylonTransformNode BabylonJS mesh
  68049. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68050. * @param animationChannelTargetPath animation target channel
  68051. * @param minFrame minimum animation frame
  68052. * @param maxFrame maximum animation frame
  68053. * @param fps frames per second of the animation
  68054. * @param inputs input key frames of the animation
  68055. * @param outputs output key frame data of the animation
  68056. * @param convertToRightHandedSystem converts the values to right-handed
  68057. * @param useQuaternion specifies if quaternions should be used
  68058. */
  68059. private static _CreateBakedAnimation;
  68060. private static _ConvertFactorToVector3OrQuaternion;
  68061. private static _SetInterpolatedValue;
  68062. /**
  68063. * Creates linear animation from the animation key frames
  68064. * @param babylonTransformNode BabylonJS mesh
  68065. * @param animation BabylonJS animation
  68066. * @param animationChannelTargetPath The target animation channel
  68067. * @param frameDelta The difference between the last and first frame of the animation
  68068. * @param inputs Array to store the key frame times
  68069. * @param outputs Array to store the key frame data
  68070. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68071. * @param useQuaternion Specifies if quaternions are used in the animation
  68072. */
  68073. private static _CreateLinearOrStepAnimation;
  68074. /**
  68075. * Creates cubic spline animation from the animation key frames
  68076. * @param babylonTransformNode BabylonJS mesh
  68077. * @param animation BabylonJS animation
  68078. * @param animationChannelTargetPath The target animation channel
  68079. * @param frameDelta The difference between the last and first frame of the animation
  68080. * @param inputs Array to store the key frame times
  68081. * @param outputs Array to store the key frame data
  68082. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68083. * @param useQuaternion Specifies if quaternions are used in the animation
  68084. */
  68085. private static _CreateCubicSplineAnimation;
  68086. private static _GetBasePositionRotationOrScale;
  68087. /**
  68088. * Adds a key frame value
  68089. * @param keyFrame
  68090. * @param animation
  68091. * @param outputs
  68092. * @param animationChannelTargetPath
  68093. * @param basePositionRotationOrScale
  68094. * @param convertToRightHandedSystem
  68095. * @param useQuaternion
  68096. */
  68097. private static _AddKeyframeValue;
  68098. /**
  68099. * Determine the interpolation based on the key frames
  68100. * @param keyFrames
  68101. * @param animationChannelTargetPath
  68102. * @param useQuaternion
  68103. */
  68104. private static _DeduceInterpolation;
  68105. /**
  68106. * Adds an input tangent or output tangent to the output data
  68107. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68108. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68109. * @param outputs The animation data by keyframe
  68110. * @param animationChannelTargetPath The target animation channel
  68111. * @param interpolation The interpolation type
  68112. * @param keyFrame The key frame with the animation data
  68113. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68114. * @param useQuaternion Specifies if quaternions are used
  68115. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68116. */
  68117. private static AddSplineTangent;
  68118. /**
  68119. * Get the minimum and maximum key frames' frame values
  68120. * @param keyFrames animation key frames
  68121. * @returns the minimum and maximum key frame value
  68122. */
  68123. private static calculateMinMaxKeyFrames;
  68124. }
  68125. }
  68126. declare module BABYLON.GLTF2.Exporter {
  68127. /** @hidden */
  68128. export var textureTransformPixelShader: {
  68129. name: string;
  68130. shader: string;
  68131. };
  68132. }
  68133. declare module BABYLON.GLTF2.Exporter.Extensions {
  68134. /**
  68135. * @hidden
  68136. */
  68137. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68138. /** Name of this extension */
  68139. readonly name: string;
  68140. /** Defines whether this extension is enabled */
  68141. enabled: boolean;
  68142. /** Defines whether this extension is required */
  68143. required: boolean;
  68144. /** Reference to the glTF exporter */
  68145. private _exporter;
  68146. constructor(exporter: _Exporter);
  68147. dispose(): void;
  68148. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68149. /**
  68150. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68151. * @param babylonTexture
  68152. * @param offset
  68153. * @param rotation
  68154. * @param scale
  68155. * @param scene
  68156. */
  68157. private _textureTransformTextureAsync;
  68158. }
  68159. }
  68160. declare module BABYLON.GLTF2.Exporter.Extensions {
  68161. /**
  68162. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68163. */
  68164. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68165. /** The name of this extension. */
  68166. readonly name: string;
  68167. /** Defines whether this extension is enabled. */
  68168. enabled: boolean;
  68169. /** Defines whether this extension is required */
  68170. required: boolean;
  68171. /** Reference to the glTF exporter */
  68172. private _exporter;
  68173. private _lights;
  68174. /** @hidden */
  68175. constructor(exporter: _Exporter);
  68176. /** @hidden */
  68177. dispose(): void;
  68178. /** @hidden */
  68179. onExporting(): void;
  68180. /**
  68181. * Define this method to modify the default behavior when exporting a node
  68182. * @param context The context when exporting the node
  68183. * @param node glTF node
  68184. * @param babylonNode BabylonJS node
  68185. * @returns nullable INode promise
  68186. */
  68187. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68188. }
  68189. }
  68190. declare module BABYLON {
  68191. /**
  68192. * Class for generating STL data from a Babylon scene.
  68193. */
  68194. export class STLExport {
  68195. /**
  68196. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68197. * @param meshes list defines the mesh to serialize
  68198. * @param download triggers the automatic download of the file.
  68199. * @param fileName changes the downloads fileName.
  68200. * @param binary changes the STL to a binary type.
  68201. * @param isLittleEndian toggle for binary type exporter.
  68202. * @returns the STL as UTF8 string
  68203. */
  68204. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68205. }
  68206. }
  68207. /**
  68208. * @ignoreChildren
  68209. * @ignore
  68210. */
  68211. declare module "babylonjs-gltf2interface" {
  68212. export = BABYLON.GLTF2;
  68213. }
  68214. /**
  68215. * Module for glTF 2.0 Interface
  68216. * @ignoreChildren
  68217. * @ignore
  68218. */
  68219. declare module BABYLON.GLTF2 {
  68220. /**
  68221. * The datatype of the components in the attribute
  68222. */
  68223. const enum AccessorComponentType {
  68224. /**
  68225. * Byte
  68226. */
  68227. BYTE = 5120,
  68228. /**
  68229. * Unsigned Byte
  68230. */
  68231. UNSIGNED_BYTE = 5121,
  68232. /**
  68233. * Short
  68234. */
  68235. SHORT = 5122,
  68236. /**
  68237. * Unsigned Short
  68238. */
  68239. UNSIGNED_SHORT = 5123,
  68240. /**
  68241. * Unsigned Int
  68242. */
  68243. UNSIGNED_INT = 5125,
  68244. /**
  68245. * Float
  68246. */
  68247. FLOAT = 5126,
  68248. }
  68249. /**
  68250. * Specifies if the attirbute is a scalar, vector, or matrix
  68251. */
  68252. const enum AccessorType {
  68253. /**
  68254. * Scalar
  68255. */
  68256. SCALAR = "SCALAR",
  68257. /**
  68258. * Vector2
  68259. */
  68260. VEC2 = "VEC2",
  68261. /**
  68262. * Vector3
  68263. */
  68264. VEC3 = "VEC3",
  68265. /**
  68266. * Vector4
  68267. */
  68268. VEC4 = "VEC4",
  68269. /**
  68270. * Matrix2x2
  68271. */
  68272. MAT2 = "MAT2",
  68273. /**
  68274. * Matrix3x3
  68275. */
  68276. MAT3 = "MAT3",
  68277. /**
  68278. * Matrix4x4
  68279. */
  68280. MAT4 = "MAT4",
  68281. }
  68282. /**
  68283. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68284. */
  68285. const enum AnimationChannelTargetPath {
  68286. /**
  68287. * Translation
  68288. */
  68289. TRANSLATION = "translation",
  68290. /**
  68291. * Rotation
  68292. */
  68293. ROTATION = "rotation",
  68294. /**
  68295. * Scale
  68296. */
  68297. SCALE = "scale",
  68298. /**
  68299. * Weights
  68300. */
  68301. WEIGHTS = "weights",
  68302. }
  68303. /**
  68304. * Interpolation algorithm
  68305. */
  68306. const enum AnimationSamplerInterpolation {
  68307. /**
  68308. * The animated values are linearly interpolated between keyframes
  68309. */
  68310. LINEAR = "LINEAR",
  68311. /**
  68312. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68313. */
  68314. STEP = "STEP",
  68315. /**
  68316. * The animation's interpolation is computed using a cubic spline with specified tangents
  68317. */
  68318. CUBICSPLINE = "CUBICSPLINE",
  68319. }
  68320. /**
  68321. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68322. */
  68323. const enum CameraType {
  68324. /**
  68325. * A perspective camera containing properties to create a perspective projection matrix
  68326. */
  68327. PERSPECTIVE = "perspective",
  68328. /**
  68329. * An orthographic camera containing properties to create an orthographic projection matrix
  68330. */
  68331. ORTHOGRAPHIC = "orthographic",
  68332. }
  68333. /**
  68334. * The mime-type of the image
  68335. */
  68336. const enum ImageMimeType {
  68337. /**
  68338. * JPEG Mime-type
  68339. */
  68340. JPEG = "image/jpeg",
  68341. /**
  68342. * PNG Mime-type
  68343. */
  68344. PNG = "image/png",
  68345. }
  68346. /**
  68347. * The alpha rendering mode of the material
  68348. */
  68349. const enum MaterialAlphaMode {
  68350. /**
  68351. * The alpha value is ignored and the rendered output is fully opaque
  68352. */
  68353. OPAQUE = "OPAQUE",
  68354. /**
  68355. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68356. */
  68357. MASK = "MASK",
  68358. /**
  68359. * 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)
  68360. */
  68361. BLEND = "BLEND",
  68362. }
  68363. /**
  68364. * The type of the primitives to render
  68365. */
  68366. const enum MeshPrimitiveMode {
  68367. /**
  68368. * Points
  68369. */
  68370. POINTS = 0,
  68371. /**
  68372. * Lines
  68373. */
  68374. LINES = 1,
  68375. /**
  68376. * Line Loop
  68377. */
  68378. LINE_LOOP = 2,
  68379. /**
  68380. * Line Strip
  68381. */
  68382. LINE_STRIP = 3,
  68383. /**
  68384. * Triangles
  68385. */
  68386. TRIANGLES = 4,
  68387. /**
  68388. * Triangle Strip
  68389. */
  68390. TRIANGLE_STRIP = 5,
  68391. /**
  68392. * Triangle Fan
  68393. */
  68394. TRIANGLE_FAN = 6,
  68395. }
  68396. /**
  68397. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68398. */
  68399. const enum TextureMagFilter {
  68400. /**
  68401. * Nearest
  68402. */
  68403. NEAREST = 9728,
  68404. /**
  68405. * Linear
  68406. */
  68407. LINEAR = 9729,
  68408. }
  68409. /**
  68410. * Minification filter. All valid values correspond to WebGL enums
  68411. */
  68412. const enum TextureMinFilter {
  68413. /**
  68414. * Nearest
  68415. */
  68416. NEAREST = 9728,
  68417. /**
  68418. * Linear
  68419. */
  68420. LINEAR = 9729,
  68421. /**
  68422. * Nearest Mip-Map Nearest
  68423. */
  68424. NEAREST_MIPMAP_NEAREST = 9984,
  68425. /**
  68426. * Linear Mipmap Nearest
  68427. */
  68428. LINEAR_MIPMAP_NEAREST = 9985,
  68429. /**
  68430. * Nearest Mipmap Linear
  68431. */
  68432. NEAREST_MIPMAP_LINEAR = 9986,
  68433. /**
  68434. * Linear Mipmap Linear
  68435. */
  68436. LINEAR_MIPMAP_LINEAR = 9987,
  68437. }
  68438. /**
  68439. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68440. */
  68441. const enum TextureWrapMode {
  68442. /**
  68443. * Clamp to Edge
  68444. */
  68445. CLAMP_TO_EDGE = 33071,
  68446. /**
  68447. * Mirrored Repeat
  68448. */
  68449. MIRRORED_REPEAT = 33648,
  68450. /**
  68451. * Repeat
  68452. */
  68453. REPEAT = 10497,
  68454. }
  68455. /**
  68456. * glTF Property
  68457. */
  68458. interface IProperty {
  68459. /**
  68460. * Dictionary object with extension-specific objects
  68461. */
  68462. extensions?: {
  68463. [key: string]: any;
  68464. };
  68465. /**
  68466. * Application-Specific data
  68467. */
  68468. extras?: any;
  68469. }
  68470. /**
  68471. * glTF Child of Root Property
  68472. */
  68473. interface IChildRootProperty extends IProperty {
  68474. /**
  68475. * The user-defined name of this object
  68476. */
  68477. name?: string;
  68478. }
  68479. /**
  68480. * Indices of those attributes that deviate from their initialization value
  68481. */
  68482. interface IAccessorSparseIndices extends IProperty {
  68483. /**
  68484. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68485. */
  68486. bufferView: number;
  68487. /**
  68488. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68489. */
  68490. byteOffset?: number;
  68491. /**
  68492. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68493. */
  68494. componentType: AccessorComponentType;
  68495. }
  68496. /**
  68497. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68498. */
  68499. interface IAccessorSparseValues extends IProperty {
  68500. /**
  68501. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68502. */
  68503. bufferView: number;
  68504. /**
  68505. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68506. */
  68507. byteOffset?: number;
  68508. }
  68509. /**
  68510. * Sparse storage of attributes that deviate from their initialization value
  68511. */
  68512. interface IAccessorSparse extends IProperty {
  68513. /**
  68514. * The number of attributes encoded in this sparse accessor
  68515. */
  68516. count: number;
  68517. /**
  68518. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68519. */
  68520. indices: IAccessorSparseIndices;
  68521. /**
  68522. * 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
  68523. */
  68524. values: IAccessorSparseValues;
  68525. }
  68526. /**
  68527. * 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
  68528. */
  68529. interface IAccessor extends IChildRootProperty {
  68530. /**
  68531. * The index of the bufferview
  68532. */
  68533. bufferView?: number;
  68534. /**
  68535. * The offset relative to the start of the bufferView in bytes
  68536. */
  68537. byteOffset?: number;
  68538. /**
  68539. * The datatype of components in the attribute
  68540. */
  68541. componentType: AccessorComponentType;
  68542. /**
  68543. * Specifies whether integer data values should be normalized
  68544. */
  68545. normalized?: boolean;
  68546. /**
  68547. * The number of attributes referenced by this accessor
  68548. */
  68549. count: number;
  68550. /**
  68551. * Specifies if the attribute is a scalar, vector, or matrix
  68552. */
  68553. type: AccessorType;
  68554. /**
  68555. * Maximum value of each component in this attribute
  68556. */
  68557. max?: number[];
  68558. /**
  68559. * Minimum value of each component in this attribute
  68560. */
  68561. min?: number[];
  68562. /**
  68563. * Sparse storage of attributes that deviate from their initialization value
  68564. */
  68565. sparse?: IAccessorSparse;
  68566. }
  68567. /**
  68568. * Targets an animation's sampler at a node's property
  68569. */
  68570. interface IAnimationChannel extends IProperty {
  68571. /**
  68572. * The index of a sampler in this animation used to compute the value for the target
  68573. */
  68574. sampler: number;
  68575. /**
  68576. * The index of the node and TRS property to target
  68577. */
  68578. target: IAnimationChannelTarget;
  68579. }
  68580. /**
  68581. * The index of the node and TRS property that an animation channel targets
  68582. */
  68583. interface IAnimationChannelTarget extends IProperty {
  68584. /**
  68585. * The index of the node to target
  68586. */
  68587. node: number;
  68588. /**
  68589. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68590. */
  68591. path: AnimationChannelTargetPath;
  68592. }
  68593. /**
  68594. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68595. */
  68596. interface IAnimationSampler extends IProperty {
  68597. /**
  68598. * The index of an accessor containing keyframe input values, e.g., time
  68599. */
  68600. input: number;
  68601. /**
  68602. * Interpolation algorithm
  68603. */
  68604. interpolation?: AnimationSamplerInterpolation;
  68605. /**
  68606. * The index of an accessor, containing keyframe output values
  68607. */
  68608. output: number;
  68609. }
  68610. /**
  68611. * A keyframe animation
  68612. */
  68613. interface IAnimation extends IChildRootProperty {
  68614. /**
  68615. * An array of channels, each of which targets an animation's sampler at a node's property
  68616. */
  68617. channels: IAnimationChannel[];
  68618. /**
  68619. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68620. */
  68621. samplers: IAnimationSampler[];
  68622. }
  68623. /**
  68624. * Metadata about the glTF asset
  68625. */
  68626. interface IAsset extends IChildRootProperty {
  68627. /**
  68628. * A copyright message suitable for display to credit the content creator
  68629. */
  68630. copyright?: string;
  68631. /**
  68632. * Tool that generated this glTF model. Useful for debugging
  68633. */
  68634. generator?: string;
  68635. /**
  68636. * The glTF version that this asset targets
  68637. */
  68638. version: string;
  68639. /**
  68640. * The minimum glTF version that this asset targets
  68641. */
  68642. minVersion?: string;
  68643. }
  68644. /**
  68645. * A buffer points to binary geometry, animation, or skins
  68646. */
  68647. interface IBuffer extends IChildRootProperty {
  68648. /**
  68649. * 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
  68650. */
  68651. uri?: string;
  68652. /**
  68653. * The length of the buffer in bytes
  68654. */
  68655. byteLength: number;
  68656. }
  68657. /**
  68658. * A view into a buffer generally representing a subset of the buffer
  68659. */
  68660. interface IBufferView extends IChildRootProperty {
  68661. /**
  68662. * The index of the buffer
  68663. */
  68664. buffer: number;
  68665. /**
  68666. * The offset into the buffer in bytes
  68667. */
  68668. byteOffset?: number;
  68669. /**
  68670. * The lenth of the bufferView in bytes
  68671. */
  68672. byteLength: number;
  68673. /**
  68674. * The stride, in bytes
  68675. */
  68676. byteStride?: number;
  68677. }
  68678. /**
  68679. * An orthographic camera containing properties to create an orthographic projection matrix
  68680. */
  68681. interface ICameraOrthographic extends IProperty {
  68682. /**
  68683. * The floating-point horizontal magnification of the view. Must not be zero
  68684. */
  68685. xmag: number;
  68686. /**
  68687. * The floating-point vertical magnification of the view. Must not be zero
  68688. */
  68689. ymag: number;
  68690. /**
  68691. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68692. */
  68693. zfar: number;
  68694. /**
  68695. * The floating-point distance to the near clipping plane
  68696. */
  68697. znear: number;
  68698. }
  68699. /**
  68700. * A perspective camera containing properties to create a perspective projection matrix
  68701. */
  68702. interface ICameraPerspective extends IProperty {
  68703. /**
  68704. * The floating-point aspect ratio of the field of view
  68705. */
  68706. aspectRatio?: number;
  68707. /**
  68708. * The floating-point vertical field of view in radians
  68709. */
  68710. yfov: number;
  68711. /**
  68712. * The floating-point distance to the far clipping plane
  68713. */
  68714. zfar?: number;
  68715. /**
  68716. * The floating-point distance to the near clipping plane
  68717. */
  68718. znear: number;
  68719. }
  68720. /**
  68721. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68722. */
  68723. interface ICamera extends IChildRootProperty {
  68724. /**
  68725. * An orthographic camera containing properties to create an orthographic projection matrix
  68726. */
  68727. orthographic?: ICameraOrthographic;
  68728. /**
  68729. * A perspective camera containing properties to create a perspective projection matrix
  68730. */
  68731. perspective?: ICameraPerspective;
  68732. /**
  68733. * Specifies if the camera uses a perspective or orthographic projection
  68734. */
  68735. type: CameraType;
  68736. }
  68737. /**
  68738. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  68739. */
  68740. interface IImage extends IChildRootProperty {
  68741. /**
  68742. * 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
  68743. */
  68744. uri?: string;
  68745. /**
  68746. * The image's MIME type
  68747. */
  68748. mimeType?: ImageMimeType;
  68749. /**
  68750. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  68751. */
  68752. bufferView?: number;
  68753. }
  68754. /**
  68755. * Material Normal Texture Info
  68756. */
  68757. interface IMaterialNormalTextureInfo extends ITextureInfo {
  68758. /**
  68759. * The scalar multiplier applied to each normal vector of the normal texture
  68760. */
  68761. scale?: number;
  68762. }
  68763. /**
  68764. * Material Occlusion Texture Info
  68765. */
  68766. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  68767. /**
  68768. * A scalar multiplier controlling the amount of occlusion applied
  68769. */
  68770. strength?: number;
  68771. }
  68772. /**
  68773. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68774. */
  68775. interface IMaterialPbrMetallicRoughness {
  68776. /**
  68777. * The material's base color factor
  68778. */
  68779. baseColorFactor?: number[];
  68780. /**
  68781. * The base color texture
  68782. */
  68783. baseColorTexture?: ITextureInfo;
  68784. /**
  68785. * The metalness of the material
  68786. */
  68787. metallicFactor?: number;
  68788. /**
  68789. * The roughness of the material
  68790. */
  68791. roughnessFactor?: number;
  68792. /**
  68793. * The metallic-roughness texture
  68794. */
  68795. metallicRoughnessTexture?: ITextureInfo;
  68796. }
  68797. /**
  68798. * The material appearance of a primitive
  68799. */
  68800. interface IMaterial extends IChildRootProperty {
  68801. /**
  68802. * 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
  68803. */
  68804. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68805. /**
  68806. * The normal map texture
  68807. */
  68808. normalTexture?: IMaterialNormalTextureInfo;
  68809. /**
  68810. * The occlusion map texture
  68811. */
  68812. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68813. /**
  68814. * The emissive map texture
  68815. */
  68816. emissiveTexture?: ITextureInfo;
  68817. /**
  68818. * 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
  68819. */
  68820. emissiveFactor?: number[];
  68821. /**
  68822. * The alpha rendering mode of the material
  68823. */
  68824. alphaMode?: MaterialAlphaMode;
  68825. /**
  68826. * The alpha cutoff value of the material
  68827. */
  68828. alphaCutoff?: number;
  68829. /**
  68830. * Specifies whether the material is double sided
  68831. */
  68832. doubleSided?: boolean;
  68833. }
  68834. /**
  68835. * Geometry to be rendered with the given material
  68836. */
  68837. interface IMeshPrimitive extends IProperty {
  68838. /**
  68839. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68840. */
  68841. attributes: {
  68842. [name: string]: number;
  68843. };
  68844. /**
  68845. * The index of the accessor that contains the indices
  68846. */
  68847. indices?: number;
  68848. /**
  68849. * The index of the material to apply to this primitive when rendering
  68850. */
  68851. material?: number;
  68852. /**
  68853. * The type of primitives to render. All valid values correspond to WebGL enums
  68854. */
  68855. mode?: MeshPrimitiveMode;
  68856. /**
  68857. * 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
  68858. */
  68859. targets?: {
  68860. [name: string]: number;
  68861. }[];
  68862. }
  68863. /**
  68864. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68865. */
  68866. interface IMesh extends IChildRootProperty {
  68867. /**
  68868. * An array of primitives, each defining geometry to be rendered with a material
  68869. */
  68870. primitives: IMeshPrimitive[];
  68871. /**
  68872. * Array of weights to be applied to the Morph Targets
  68873. */
  68874. weights?: number[];
  68875. }
  68876. /**
  68877. * A node in the node hierarchy
  68878. */
  68879. interface INode extends IChildRootProperty {
  68880. /**
  68881. * The index of the camera referenced by this node
  68882. */
  68883. camera?: number;
  68884. /**
  68885. * The indices of this node's children
  68886. */
  68887. children?: number[];
  68888. /**
  68889. * The index of the skin referenced by this node
  68890. */
  68891. skin?: number;
  68892. /**
  68893. * A floating-point 4x4 transformation matrix stored in column-major order
  68894. */
  68895. matrix?: number[];
  68896. /**
  68897. * The index of the mesh in this node
  68898. */
  68899. mesh?: number;
  68900. /**
  68901. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68902. */
  68903. rotation?: number[];
  68904. /**
  68905. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68906. */
  68907. scale?: number[];
  68908. /**
  68909. * The node's translation along the x, y, and z axes
  68910. */
  68911. translation?: number[];
  68912. /**
  68913. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68914. */
  68915. weights?: number[];
  68916. }
  68917. /**
  68918. * Texture sampler properties for filtering and wrapping modes
  68919. */
  68920. interface ISampler extends IChildRootProperty {
  68921. /**
  68922. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68923. */
  68924. magFilter?: TextureMagFilter;
  68925. /**
  68926. * Minification filter. All valid values correspond to WebGL enums
  68927. */
  68928. minFilter?: TextureMinFilter;
  68929. /**
  68930. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68931. */
  68932. wrapS?: TextureWrapMode;
  68933. /**
  68934. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68935. */
  68936. wrapT?: TextureWrapMode;
  68937. }
  68938. /**
  68939. * The root nodes of a scene
  68940. */
  68941. interface IScene extends IChildRootProperty {
  68942. /**
  68943. * The indices of each root node
  68944. */
  68945. nodes: number[];
  68946. }
  68947. /**
  68948. * Joints and matrices defining a skin
  68949. */
  68950. interface ISkin extends IChildRootProperty {
  68951. /**
  68952. * 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
  68953. */
  68954. inverseBindMatrices?: number;
  68955. /**
  68956. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  68957. */
  68958. skeleton?: number;
  68959. /**
  68960. * 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)
  68961. */
  68962. joints: number[];
  68963. }
  68964. /**
  68965. * A texture and its sampler
  68966. */
  68967. interface ITexture extends IChildRootProperty {
  68968. /**
  68969. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  68970. */
  68971. sampler?: number;
  68972. /**
  68973. * The index of the image used by this texture
  68974. */
  68975. source: number;
  68976. }
  68977. /**
  68978. * Reference to a texture
  68979. */
  68980. interface ITextureInfo extends IProperty {
  68981. /**
  68982. * The index of the texture
  68983. */
  68984. index: number;
  68985. /**
  68986. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  68987. */
  68988. texCoord?: number;
  68989. }
  68990. /**
  68991. * The root object for a glTF asset
  68992. */
  68993. interface IGLTF extends IProperty {
  68994. /**
  68995. * An array of accessors. An accessor is a typed view into a bufferView
  68996. */
  68997. accessors?: IAccessor[];
  68998. /**
  68999. * An array of keyframe animations
  69000. */
  69001. animations?: IAnimation[];
  69002. /**
  69003. * Metadata about the glTF asset
  69004. */
  69005. asset: IAsset;
  69006. /**
  69007. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69008. */
  69009. buffers?: IBuffer[];
  69010. /**
  69011. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69012. */
  69013. bufferViews?: IBufferView[];
  69014. /**
  69015. * An array of cameras
  69016. */
  69017. cameras?: ICamera[];
  69018. /**
  69019. * Names of glTF extensions used somewhere in this asset
  69020. */
  69021. extensionsUsed?: string[];
  69022. /**
  69023. * Names of glTF extensions required to properly load this asset
  69024. */
  69025. extensionsRequired?: string[];
  69026. /**
  69027. * An array of images. An image defines data used to create a texture
  69028. */
  69029. images?: IImage[];
  69030. /**
  69031. * An array of materials. A material defines the appearance of a primitive
  69032. */
  69033. materials?: IMaterial[];
  69034. /**
  69035. * An array of meshes. A mesh is a set of primitives to be rendered
  69036. */
  69037. meshes?: IMesh[];
  69038. /**
  69039. * An array of nodes
  69040. */
  69041. nodes?: INode[];
  69042. /**
  69043. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69044. */
  69045. samplers?: ISampler[];
  69046. /**
  69047. * The index of the default scene
  69048. */
  69049. scene?: number;
  69050. /**
  69051. * An array of scenes
  69052. */
  69053. scenes?: IScene[];
  69054. /**
  69055. * An array of skins. A skin is defined by joints and matrices
  69056. */
  69057. skins?: ISkin[];
  69058. /**
  69059. * An array of textures
  69060. */
  69061. textures?: ITexture[];
  69062. }
  69063. /**
  69064. * The glTF validation results
  69065. */
  69066. interface IGLTFValidationResults {
  69067. info: {
  69068. generator: string;
  69069. hasAnimations: boolean;
  69070. hasDefaultScene: boolean;
  69071. hasMaterials: boolean;
  69072. hasMorphTargets: boolean;
  69073. hasSkins: boolean;
  69074. hasTextures: boolean;
  69075. maxAttributesUsed: number;
  69076. primitivesCount: number
  69077. };
  69078. issues: {
  69079. messages: Array<string>;
  69080. numErrors: number;
  69081. numHints: number;
  69082. numInfos: number;
  69083. numWarnings: number;
  69084. truncated: boolean
  69085. };
  69086. mimeType: string;
  69087. uri: string;
  69088. validatedAt: string;
  69089. validatorVersion: string;
  69090. }
  69091. /**
  69092. * The glTF validation options
  69093. */
  69094. interface IGLTFValidationOptions {
  69095. uri?: string;
  69096. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69097. validateAccessorData?: boolean;
  69098. maxIssues?: number;
  69099. ignoredIssues?: Array<string>;
  69100. severityOverrides?: Object;
  69101. }
  69102. /**
  69103. * The glTF validator object
  69104. */
  69105. interface IGLTFValidator {
  69106. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69107. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69108. }
  69109. }
  69110. declare module BABYLON {
  69111. /** @hidden */
  69112. export var cellPixelShader: {
  69113. name: string;
  69114. shader: string;
  69115. };
  69116. }
  69117. declare module BABYLON {
  69118. /** @hidden */
  69119. export var cellVertexShader: {
  69120. name: string;
  69121. shader: string;
  69122. };
  69123. }
  69124. declare module BABYLON {
  69125. export class CellMaterial extends BABYLON.PushMaterial {
  69126. private _diffuseTexture;
  69127. diffuseTexture: BABYLON.BaseTexture;
  69128. diffuseColor: BABYLON.Color3;
  69129. _computeHighLevel: boolean;
  69130. computeHighLevel: boolean;
  69131. private _disableLighting;
  69132. disableLighting: boolean;
  69133. private _maxSimultaneousLights;
  69134. maxSimultaneousLights: number;
  69135. private _renderId;
  69136. constructor(name: string, scene: BABYLON.Scene);
  69137. needAlphaBlending(): boolean;
  69138. needAlphaTesting(): boolean;
  69139. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69140. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69141. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69142. getAnimatables(): BABYLON.IAnimatable[];
  69143. getActiveTextures(): BABYLON.BaseTexture[];
  69144. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69145. dispose(forceDisposeEffect?: boolean): void;
  69146. getClassName(): string;
  69147. clone(name: string): CellMaterial;
  69148. serialize(): any;
  69149. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69150. }
  69151. }
  69152. declare module BABYLON {
  69153. export class CustomShaderStructure {
  69154. FragmentStore: string;
  69155. VertexStore: string;
  69156. constructor();
  69157. }
  69158. export class ShaderSpecialParts {
  69159. constructor();
  69160. Fragment_Begin: string;
  69161. Fragment_Definitions: string;
  69162. Fragment_MainBegin: string;
  69163. Fragment_Custom_Diffuse: string;
  69164. Fragment_Before_Lights: string;
  69165. Fragment_Before_Fog: string;
  69166. Fragment_Custom_Alpha: string;
  69167. Fragment_Before_FragColor: string;
  69168. Vertex_Begin: string;
  69169. Vertex_Definitions: string;
  69170. Vertex_MainBegin: string;
  69171. Vertex_Before_PositionUpdated: string;
  69172. Vertex_Before_NormalUpdated: string;
  69173. Vertex_MainEnd: string;
  69174. }
  69175. export class CustomMaterial extends BABYLON.StandardMaterial {
  69176. static ShaderIndexer: number;
  69177. CustomParts: ShaderSpecialParts;
  69178. _isCreatedShader: boolean;
  69179. _createdShaderName: string;
  69180. _customUniform: string[];
  69181. _newUniforms: string[];
  69182. _newUniformInstances: any[];
  69183. _newSamplerInstances: BABYLON.Texture[];
  69184. FragmentShader: string;
  69185. VertexShader: string;
  69186. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69187. ReviewUniform(name: string, arr: string[]): string[];
  69188. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69189. constructor(name: string, scene: BABYLON.Scene);
  69190. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69191. Fragment_Begin(shaderPart: string): CustomMaterial;
  69192. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69193. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69194. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69195. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69196. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69197. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69198. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69199. Vertex_Begin(shaderPart: string): CustomMaterial;
  69200. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69201. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69202. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69203. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69204. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69205. }
  69206. }
  69207. declare module BABYLON {
  69208. export class ShaderAlebdoParts {
  69209. constructor();
  69210. Fragment_Begin: string;
  69211. Fragment_Definitions: string;
  69212. Fragment_MainBegin: string;
  69213. Fragment_Custom_Albedo: string;
  69214. Fragment_Before_Lights: string;
  69215. Fragment_Custom_MetallicRoughness: string;
  69216. Fragment_Custom_MicroSurface: string;
  69217. Fragment_Before_Fog: string;
  69218. Fragment_Custom_Alpha: string;
  69219. Fragment_Before_FragColor: string;
  69220. Vertex_Begin: string;
  69221. Vertex_Definitions: string;
  69222. Vertex_MainBegin: string;
  69223. Vertex_Before_PositionUpdated: string;
  69224. Vertex_Before_NormalUpdated: string;
  69225. Vertex_MainEnd: string;
  69226. }
  69227. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69228. static ShaderIndexer: number;
  69229. CustomParts: ShaderAlebdoParts;
  69230. _isCreatedShader: boolean;
  69231. _createdShaderName: string;
  69232. _customUniform: string[];
  69233. _newUniforms: string[];
  69234. _newUniformInstances: any[];
  69235. _newSamplerInstances: BABYLON.Texture[];
  69236. FragmentShader: string;
  69237. VertexShader: string;
  69238. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69239. ReviewUniform(name: string, arr: string[]): string[];
  69240. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69241. constructor(name: string, scene: BABYLON.Scene);
  69242. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69243. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69244. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69245. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69246. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69247. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69248. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69249. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69250. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69251. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69252. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69253. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69254. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69255. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69256. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69257. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69258. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69259. }
  69260. }
  69261. declare module BABYLON {
  69262. /** @hidden */
  69263. export var firePixelShader: {
  69264. name: string;
  69265. shader: string;
  69266. };
  69267. }
  69268. declare module BABYLON {
  69269. /** @hidden */
  69270. export var fireVertexShader: {
  69271. name: string;
  69272. shader: string;
  69273. };
  69274. }
  69275. declare module BABYLON {
  69276. export class FireMaterial extends BABYLON.PushMaterial {
  69277. private _diffuseTexture;
  69278. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69279. private _distortionTexture;
  69280. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69281. private _opacityTexture;
  69282. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69283. diffuseColor: BABYLON.Color3;
  69284. speed: number;
  69285. private _scaledDiffuse;
  69286. private _renderId;
  69287. private _lastTime;
  69288. constructor(name: string, scene: BABYLON.Scene);
  69289. needAlphaBlending(): boolean;
  69290. needAlphaTesting(): boolean;
  69291. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69292. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69293. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69294. getAnimatables(): BABYLON.IAnimatable[];
  69295. getActiveTextures(): BABYLON.BaseTexture[];
  69296. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69297. getClassName(): string;
  69298. dispose(forceDisposeEffect?: boolean): void;
  69299. clone(name: string): FireMaterial;
  69300. serialize(): any;
  69301. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69302. }
  69303. }
  69304. declare module BABYLON {
  69305. /** @hidden */
  69306. export var furPixelShader: {
  69307. name: string;
  69308. shader: string;
  69309. };
  69310. }
  69311. declare module BABYLON {
  69312. /** @hidden */
  69313. export var furVertexShader: {
  69314. name: string;
  69315. shader: string;
  69316. };
  69317. }
  69318. declare module BABYLON {
  69319. export class FurMaterial extends BABYLON.PushMaterial {
  69320. private _diffuseTexture;
  69321. diffuseTexture: BABYLON.BaseTexture;
  69322. private _heightTexture;
  69323. heightTexture: BABYLON.BaseTexture;
  69324. diffuseColor: BABYLON.Color3;
  69325. furLength: number;
  69326. furAngle: number;
  69327. furColor: BABYLON.Color3;
  69328. furOffset: number;
  69329. furSpacing: number;
  69330. furGravity: BABYLON.Vector3;
  69331. furSpeed: number;
  69332. furDensity: number;
  69333. furOcclusion: number;
  69334. furTexture: BABYLON.DynamicTexture;
  69335. private _disableLighting;
  69336. disableLighting: boolean;
  69337. private _maxSimultaneousLights;
  69338. maxSimultaneousLights: number;
  69339. highLevelFur: boolean;
  69340. _meshes: BABYLON.AbstractMesh[];
  69341. private _renderId;
  69342. private _furTime;
  69343. constructor(name: string, scene: BABYLON.Scene);
  69344. furTime: number;
  69345. needAlphaBlending(): boolean;
  69346. needAlphaTesting(): boolean;
  69347. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69348. updateFur(): void;
  69349. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69350. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69351. getAnimatables(): BABYLON.IAnimatable[];
  69352. getActiveTextures(): BABYLON.BaseTexture[];
  69353. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69354. dispose(forceDisposeEffect?: boolean): void;
  69355. clone(name: string): FurMaterial;
  69356. serialize(): any;
  69357. getClassName(): string;
  69358. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69359. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69360. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69361. }
  69362. }
  69363. declare module BABYLON {
  69364. /** @hidden */
  69365. export var gradientPixelShader: {
  69366. name: string;
  69367. shader: string;
  69368. };
  69369. }
  69370. declare module BABYLON {
  69371. /** @hidden */
  69372. export var gradientVertexShader: {
  69373. name: string;
  69374. shader: string;
  69375. };
  69376. }
  69377. declare module BABYLON {
  69378. export class GradientMaterial extends BABYLON.PushMaterial {
  69379. private _maxSimultaneousLights;
  69380. maxSimultaneousLights: number;
  69381. topColor: BABYLON.Color3;
  69382. topColorAlpha: number;
  69383. bottomColor: BABYLON.Color3;
  69384. bottomColorAlpha: number;
  69385. offset: number;
  69386. scale: number;
  69387. smoothness: number;
  69388. private _disableLighting;
  69389. disableLighting: boolean;
  69390. private _renderId;
  69391. constructor(name: string, scene: BABYLON.Scene);
  69392. needAlphaBlending(): boolean;
  69393. needAlphaTesting(): boolean;
  69394. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69395. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69396. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69397. getAnimatables(): BABYLON.IAnimatable[];
  69398. dispose(forceDisposeEffect?: boolean): void;
  69399. clone(name: string): GradientMaterial;
  69400. serialize(): any;
  69401. getClassName(): string;
  69402. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69403. }
  69404. }
  69405. declare module BABYLON {
  69406. /** @hidden */
  69407. export var gridPixelShader: {
  69408. name: string;
  69409. shader: string;
  69410. };
  69411. }
  69412. declare module BABYLON {
  69413. /** @hidden */
  69414. export var gridVertexShader: {
  69415. name: string;
  69416. shader: string;
  69417. };
  69418. }
  69419. declare module BABYLON {
  69420. /**
  69421. * The grid materials allows you to wrap any shape with a grid.
  69422. * Colors are customizable.
  69423. */
  69424. export class GridMaterial extends BABYLON.PushMaterial {
  69425. /**
  69426. * Main color of the grid (e.g. between lines)
  69427. */
  69428. mainColor: BABYLON.Color3;
  69429. /**
  69430. * Color of the grid lines.
  69431. */
  69432. lineColor: BABYLON.Color3;
  69433. /**
  69434. * The scale of the grid compared to unit.
  69435. */
  69436. gridRatio: number;
  69437. /**
  69438. * Allows setting an offset for the grid lines.
  69439. */
  69440. gridOffset: BABYLON.Vector3;
  69441. /**
  69442. * The frequency of thicker lines.
  69443. */
  69444. majorUnitFrequency: number;
  69445. /**
  69446. * The visibility of minor units in the grid.
  69447. */
  69448. minorUnitVisibility: number;
  69449. /**
  69450. * The grid opacity outside of the lines.
  69451. */
  69452. opacity: number;
  69453. /**
  69454. * Determine RBG output is premultiplied by alpha value.
  69455. */
  69456. preMultiplyAlpha: boolean;
  69457. private _opacityTexture;
  69458. opacityTexture: BABYLON.BaseTexture;
  69459. private _gridControl;
  69460. private _renderId;
  69461. /**
  69462. * constructor
  69463. * @param name The name given to the material in order to identify it afterwards.
  69464. * @param scene The scene the material is used in.
  69465. */
  69466. constructor(name: string, scene: BABYLON.Scene);
  69467. /**
  69468. * Returns wehter or not the grid requires alpha blending.
  69469. */
  69470. needAlphaBlending(): boolean;
  69471. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69472. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69473. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69474. /**
  69475. * Dispose the material and its associated resources.
  69476. * @param forceDisposeEffect will also dispose the used effect when true
  69477. */
  69478. dispose(forceDisposeEffect?: boolean): void;
  69479. clone(name: string): GridMaterial;
  69480. serialize(): any;
  69481. getClassName(): string;
  69482. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69483. }
  69484. }
  69485. declare module BABYLON {
  69486. /** @hidden */
  69487. export var lavaPixelShader: {
  69488. name: string;
  69489. shader: string;
  69490. };
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export var lavaVertexShader: {
  69495. name: string;
  69496. shader: string;
  69497. };
  69498. }
  69499. declare module BABYLON {
  69500. export class LavaMaterial extends BABYLON.PushMaterial {
  69501. private _diffuseTexture;
  69502. diffuseTexture: BABYLON.BaseTexture;
  69503. noiseTexture: BABYLON.BaseTexture;
  69504. fogColor: BABYLON.Color3;
  69505. speed: number;
  69506. movingSpeed: number;
  69507. lowFrequencySpeed: number;
  69508. fogDensity: number;
  69509. private _lastTime;
  69510. diffuseColor: BABYLON.Color3;
  69511. private _disableLighting;
  69512. disableLighting: boolean;
  69513. private _unlit;
  69514. unlit: boolean;
  69515. private _maxSimultaneousLights;
  69516. maxSimultaneousLights: number;
  69517. private _scaledDiffuse;
  69518. private _renderId;
  69519. constructor(name: string, scene: BABYLON.Scene);
  69520. needAlphaBlending(): boolean;
  69521. needAlphaTesting(): boolean;
  69522. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69523. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69524. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69525. getAnimatables(): BABYLON.IAnimatable[];
  69526. getActiveTextures(): BABYLON.BaseTexture[];
  69527. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69528. dispose(forceDisposeEffect?: boolean): void;
  69529. clone(name: string): LavaMaterial;
  69530. serialize(): any;
  69531. getClassName(): string;
  69532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69533. }
  69534. }
  69535. declare module BABYLON {
  69536. /** @hidden */
  69537. export var mixPixelShader: {
  69538. name: string;
  69539. shader: string;
  69540. };
  69541. }
  69542. declare module BABYLON {
  69543. /** @hidden */
  69544. export var mixVertexShader: {
  69545. name: string;
  69546. shader: string;
  69547. };
  69548. }
  69549. declare module BABYLON {
  69550. export class MixMaterial extends BABYLON.PushMaterial {
  69551. /**
  69552. * Mix textures
  69553. */
  69554. private _mixTexture1;
  69555. mixTexture1: BABYLON.BaseTexture;
  69556. private _mixTexture2;
  69557. mixTexture2: BABYLON.BaseTexture;
  69558. /**
  69559. * Diffuse textures
  69560. */
  69561. private _diffuseTexture1;
  69562. diffuseTexture1: BABYLON.Texture;
  69563. private _diffuseTexture2;
  69564. diffuseTexture2: BABYLON.Texture;
  69565. private _diffuseTexture3;
  69566. diffuseTexture3: BABYLON.Texture;
  69567. private _diffuseTexture4;
  69568. diffuseTexture4: BABYLON.Texture;
  69569. private _diffuseTexture5;
  69570. diffuseTexture5: BABYLON.Texture;
  69571. private _diffuseTexture6;
  69572. diffuseTexture6: BABYLON.Texture;
  69573. private _diffuseTexture7;
  69574. diffuseTexture7: BABYLON.Texture;
  69575. private _diffuseTexture8;
  69576. diffuseTexture8: BABYLON.Texture;
  69577. /**
  69578. * Uniforms
  69579. */
  69580. diffuseColor: BABYLON.Color3;
  69581. specularColor: BABYLON.Color3;
  69582. specularPower: number;
  69583. private _disableLighting;
  69584. disableLighting: boolean;
  69585. private _maxSimultaneousLights;
  69586. maxSimultaneousLights: number;
  69587. private _renderId;
  69588. constructor(name: string, scene: BABYLON.Scene);
  69589. needAlphaBlending(): boolean;
  69590. needAlphaTesting(): boolean;
  69591. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69592. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69593. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69594. getAnimatables(): BABYLON.IAnimatable[];
  69595. getActiveTextures(): BABYLON.BaseTexture[];
  69596. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69597. dispose(forceDisposeEffect?: boolean): void;
  69598. clone(name: string): MixMaterial;
  69599. serialize(): any;
  69600. getClassName(): string;
  69601. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69602. }
  69603. }
  69604. declare module BABYLON {
  69605. /** @hidden */
  69606. export var normalPixelShader: {
  69607. name: string;
  69608. shader: string;
  69609. };
  69610. }
  69611. declare module BABYLON {
  69612. /** @hidden */
  69613. export var normalVertexShader: {
  69614. name: string;
  69615. shader: string;
  69616. };
  69617. }
  69618. declare module BABYLON {
  69619. export class NormalMaterial extends BABYLON.PushMaterial {
  69620. private _diffuseTexture;
  69621. diffuseTexture: BABYLON.BaseTexture;
  69622. diffuseColor: BABYLON.Color3;
  69623. private _disableLighting;
  69624. disableLighting: boolean;
  69625. private _maxSimultaneousLights;
  69626. maxSimultaneousLights: number;
  69627. private _renderId;
  69628. constructor(name: string, scene: BABYLON.Scene);
  69629. needAlphaBlending(): boolean;
  69630. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69631. needAlphaTesting(): boolean;
  69632. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69633. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69634. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69635. getAnimatables(): BABYLON.IAnimatable[];
  69636. getActiveTextures(): BABYLON.BaseTexture[];
  69637. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69638. dispose(forceDisposeEffect?: boolean): void;
  69639. clone(name: string): NormalMaterial;
  69640. serialize(): any;
  69641. getClassName(): string;
  69642. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69643. }
  69644. }
  69645. declare module BABYLON {
  69646. /** @hidden */
  69647. export var shadowOnlyPixelShader: {
  69648. name: string;
  69649. shader: string;
  69650. };
  69651. }
  69652. declare module BABYLON {
  69653. /** @hidden */
  69654. export var shadowOnlyVertexShader: {
  69655. name: string;
  69656. shader: string;
  69657. };
  69658. }
  69659. declare module BABYLON {
  69660. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69661. private _renderId;
  69662. private _activeLight;
  69663. constructor(name: string, scene: BABYLON.Scene);
  69664. shadowColor: BABYLON.Color3;
  69665. needAlphaBlending(): boolean;
  69666. needAlphaTesting(): boolean;
  69667. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69668. activeLight: BABYLON.IShadowLight;
  69669. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69670. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69671. clone(name: string): ShadowOnlyMaterial;
  69672. serialize(): any;
  69673. getClassName(): string;
  69674. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69675. }
  69676. }
  69677. declare module BABYLON {
  69678. /** @hidden */
  69679. export var simplePixelShader: {
  69680. name: string;
  69681. shader: string;
  69682. };
  69683. }
  69684. declare module BABYLON {
  69685. /** @hidden */
  69686. export var simpleVertexShader: {
  69687. name: string;
  69688. shader: string;
  69689. };
  69690. }
  69691. declare module BABYLON {
  69692. export class SimpleMaterial extends BABYLON.PushMaterial {
  69693. private _diffuseTexture;
  69694. diffuseTexture: BABYLON.BaseTexture;
  69695. diffuseColor: BABYLON.Color3;
  69696. private _disableLighting;
  69697. disableLighting: boolean;
  69698. private _maxSimultaneousLights;
  69699. maxSimultaneousLights: number;
  69700. private _renderId;
  69701. constructor(name: string, scene: BABYLON.Scene);
  69702. needAlphaBlending(): boolean;
  69703. needAlphaTesting(): boolean;
  69704. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69705. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69706. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69707. getAnimatables(): BABYLON.IAnimatable[];
  69708. getActiveTextures(): BABYLON.BaseTexture[];
  69709. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69710. dispose(forceDisposeEffect?: boolean): void;
  69711. clone(name: string): SimpleMaterial;
  69712. serialize(): any;
  69713. getClassName(): string;
  69714. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69715. }
  69716. }
  69717. declare module BABYLON {
  69718. /** @hidden */
  69719. export var skyPixelShader: {
  69720. name: string;
  69721. shader: string;
  69722. };
  69723. }
  69724. declare module BABYLON {
  69725. /** @hidden */
  69726. export var skyVertexShader: {
  69727. name: string;
  69728. shader: string;
  69729. };
  69730. }
  69731. declare module BABYLON {
  69732. /**
  69733. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  69734. * @see https://doc.babylonjs.com/extensions/sky
  69735. */
  69736. export class SkyMaterial extends BABYLON.PushMaterial {
  69737. /**
  69738. * Defines the overall luminance of sky in interval ]0, 1[.
  69739. */
  69740. luminance: number;
  69741. /**
  69742. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  69743. */
  69744. turbidity: number;
  69745. /**
  69746. * Defines the sky appearance (light intensity).
  69747. */
  69748. rayleigh: number;
  69749. /**
  69750. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  69751. */
  69752. mieCoefficient: number;
  69753. /**
  69754. * Defines the amount of haze particles following the Mie scattering theory.
  69755. */
  69756. mieDirectionalG: number;
  69757. /**
  69758. * Defines the distance of the sun according to the active scene camera.
  69759. */
  69760. distance: number;
  69761. /**
  69762. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  69763. * "inclined".
  69764. */
  69765. inclination: number;
  69766. /**
  69767. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  69768. * an object direction and a reference direction.
  69769. */
  69770. azimuth: number;
  69771. /**
  69772. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  69773. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  69774. */
  69775. sunPosition: BABYLON.Vector3;
  69776. /**
  69777. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  69778. * .sunPosition property.
  69779. */
  69780. useSunPosition: boolean;
  69781. /**
  69782. * Defines an offset vector used to get a horizon offset.
  69783. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69784. */
  69785. cameraOffset: BABYLON.Vector3;
  69786. private _cameraPosition;
  69787. private _renderId;
  69788. /**
  69789. * Instantiates a new sky material.
  69790. * This material allows to create dynamic and texture free
  69791. * effects for skyboxes by taking care of the atmosphere state.
  69792. * @see https://doc.babylonjs.com/extensions/sky
  69793. * @param name Define the name of the material in the scene
  69794. * @param scene Define the scene the material belong to
  69795. */
  69796. constructor(name: string, scene: BABYLON.Scene);
  69797. /**
  69798. * Specifies if the material will require alpha blending
  69799. * @returns a boolean specifying if alpha blending is needed
  69800. */
  69801. needAlphaBlending(): boolean;
  69802. /**
  69803. * Specifies if this material should be rendered in alpha test mode
  69804. * @returns false as the sky material doesn't need alpha testing.
  69805. */
  69806. needAlphaTesting(): boolean;
  69807. /**
  69808. * Get the texture used for alpha test purpose.
  69809. * @returns null as the sky material has no texture.
  69810. */
  69811. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69812. /**
  69813. * Get if the submesh is ready to be used and all its information available.
  69814. * Child classes can use it to update shaders
  69815. * @param mesh defines the mesh to check
  69816. * @param subMesh defines which submesh to check
  69817. * @param useInstances specifies that instances should be used
  69818. * @returns a boolean indicating that the submesh is ready or not
  69819. */
  69820. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69821. /**
  69822. * Binds the submesh to this material by preparing the effect and shader to draw
  69823. * @param world defines the world transformation matrix
  69824. * @param mesh defines the mesh containing the submesh
  69825. * @param subMesh defines the submesh to bind the material to
  69826. */
  69827. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69828. /**
  69829. * Get the list of animatables in the material.
  69830. * @returns the list of animatables object used in the material
  69831. */
  69832. getAnimatables(): BABYLON.IAnimatable[];
  69833. /**
  69834. * Disposes the material
  69835. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69836. */
  69837. dispose(forceDisposeEffect?: boolean): void;
  69838. /**
  69839. * Makes a duplicate of the material, and gives it a new name
  69840. * @param name defines the new name for the duplicated material
  69841. * @returns the cloned material
  69842. */
  69843. clone(name: string): SkyMaterial;
  69844. /**
  69845. * Serializes this material in a JSON representation
  69846. * @returns the serialized material object
  69847. */
  69848. serialize(): any;
  69849. /**
  69850. * Gets the current class name of the material e.g. "SkyMaterial"
  69851. * Mainly use in serialization.
  69852. * @returns the class name
  69853. */
  69854. getClassName(): string;
  69855. /**
  69856. * Creates a sky material from parsed material data
  69857. * @param source defines the JSON representation of the material
  69858. * @param scene defines the hosting scene
  69859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69860. * @returns a new sky material
  69861. */
  69862. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69863. }
  69864. }
  69865. declare module BABYLON {
  69866. /** @hidden */
  69867. export var terrainPixelShader: {
  69868. name: string;
  69869. shader: string;
  69870. };
  69871. }
  69872. declare module BABYLON {
  69873. /** @hidden */
  69874. export var terrainVertexShader: {
  69875. name: string;
  69876. shader: string;
  69877. };
  69878. }
  69879. declare module BABYLON {
  69880. export class TerrainMaterial extends BABYLON.PushMaterial {
  69881. private _mixTexture;
  69882. mixTexture: BABYLON.BaseTexture;
  69883. private _diffuseTexture1;
  69884. diffuseTexture1: BABYLON.Texture;
  69885. private _diffuseTexture2;
  69886. diffuseTexture2: BABYLON.Texture;
  69887. private _diffuseTexture3;
  69888. diffuseTexture3: BABYLON.Texture;
  69889. private _bumpTexture1;
  69890. bumpTexture1: BABYLON.Texture;
  69891. private _bumpTexture2;
  69892. bumpTexture2: BABYLON.Texture;
  69893. private _bumpTexture3;
  69894. bumpTexture3: BABYLON.Texture;
  69895. diffuseColor: BABYLON.Color3;
  69896. specularColor: BABYLON.Color3;
  69897. specularPower: number;
  69898. private _disableLighting;
  69899. disableLighting: boolean;
  69900. private _maxSimultaneousLights;
  69901. maxSimultaneousLights: number;
  69902. private _renderId;
  69903. constructor(name: string, scene: BABYLON.Scene);
  69904. needAlphaBlending(): boolean;
  69905. needAlphaTesting(): boolean;
  69906. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69907. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69908. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69909. getAnimatables(): BABYLON.IAnimatable[];
  69910. getActiveTextures(): BABYLON.BaseTexture[];
  69911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69912. dispose(forceDisposeEffect?: boolean): void;
  69913. clone(name: string): TerrainMaterial;
  69914. serialize(): any;
  69915. getClassName(): string;
  69916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69917. }
  69918. }
  69919. declare module BABYLON {
  69920. /** @hidden */
  69921. export var triplanarPixelShader: {
  69922. name: string;
  69923. shader: string;
  69924. };
  69925. }
  69926. declare module BABYLON {
  69927. /** @hidden */
  69928. export var triplanarVertexShader: {
  69929. name: string;
  69930. shader: string;
  69931. };
  69932. }
  69933. declare module BABYLON {
  69934. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69935. mixTexture: BABYLON.BaseTexture;
  69936. private _diffuseTextureX;
  69937. diffuseTextureX: BABYLON.BaseTexture;
  69938. private _diffuseTextureY;
  69939. diffuseTextureY: BABYLON.BaseTexture;
  69940. private _diffuseTextureZ;
  69941. diffuseTextureZ: BABYLON.BaseTexture;
  69942. private _normalTextureX;
  69943. normalTextureX: BABYLON.BaseTexture;
  69944. private _normalTextureY;
  69945. normalTextureY: BABYLON.BaseTexture;
  69946. private _normalTextureZ;
  69947. normalTextureZ: BABYLON.BaseTexture;
  69948. tileSize: number;
  69949. diffuseColor: BABYLON.Color3;
  69950. specularColor: BABYLON.Color3;
  69951. specularPower: number;
  69952. private _disableLighting;
  69953. disableLighting: boolean;
  69954. private _maxSimultaneousLights;
  69955. maxSimultaneousLights: number;
  69956. private _renderId;
  69957. constructor(name: string, scene: BABYLON.Scene);
  69958. needAlphaBlending(): boolean;
  69959. needAlphaTesting(): boolean;
  69960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69963. getAnimatables(): BABYLON.IAnimatable[];
  69964. getActiveTextures(): BABYLON.BaseTexture[];
  69965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69966. dispose(forceDisposeEffect?: boolean): void;
  69967. clone(name: string): TriPlanarMaterial;
  69968. serialize(): any;
  69969. getClassName(): string;
  69970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  69971. }
  69972. }
  69973. declare module BABYLON {
  69974. /** @hidden */
  69975. export var waterPixelShader: {
  69976. name: string;
  69977. shader: string;
  69978. };
  69979. }
  69980. declare module BABYLON {
  69981. /** @hidden */
  69982. export var waterVertexShader: {
  69983. name: string;
  69984. shader: string;
  69985. };
  69986. }
  69987. declare module BABYLON {
  69988. export class WaterMaterial extends BABYLON.PushMaterial {
  69989. renderTargetSize: BABYLON.Vector2;
  69990. private _bumpTexture;
  69991. bumpTexture: BABYLON.BaseTexture;
  69992. diffuseColor: BABYLON.Color3;
  69993. specularColor: BABYLON.Color3;
  69994. specularPower: number;
  69995. private _disableLighting;
  69996. disableLighting: boolean;
  69997. private _maxSimultaneousLights;
  69998. maxSimultaneousLights: number;
  69999. /**
  70000. * @param {number}: Represents the wind force
  70001. */
  70002. windForce: number;
  70003. /**
  70004. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70005. */
  70006. windDirection: BABYLON.Vector2;
  70007. /**
  70008. * @param {number}: Wave height, represents the height of the waves
  70009. */
  70010. waveHeight: number;
  70011. /**
  70012. * @param {number}: Bump height, represents the bump height related to the bump map
  70013. */
  70014. bumpHeight: number;
  70015. /**
  70016. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70017. */
  70018. private _bumpSuperimpose;
  70019. bumpSuperimpose: boolean;
  70020. /**
  70021. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70022. */
  70023. private _fresnelSeparate;
  70024. fresnelSeparate: boolean;
  70025. /**
  70026. * @param {boolean}: bump Waves modify the reflection.
  70027. */
  70028. private _bumpAffectsReflection;
  70029. bumpAffectsReflection: boolean;
  70030. /**
  70031. * @param {number}: The water color blended with the refraction (near)
  70032. */
  70033. waterColor: BABYLON.Color3;
  70034. /**
  70035. * @param {number}: The blend factor related to the water color
  70036. */
  70037. colorBlendFactor: number;
  70038. /**
  70039. * @param {number}: The water color blended with the reflection (far)
  70040. */
  70041. waterColor2: BABYLON.Color3;
  70042. /**
  70043. * @param {number}: The blend factor related to the water color (reflection, far)
  70044. */
  70045. colorBlendFactor2: number;
  70046. /**
  70047. * @param {number}: Represents the maximum length of a wave
  70048. */
  70049. waveLength: number;
  70050. /**
  70051. * @param {number}: Defines the waves speed
  70052. */
  70053. waveSpeed: number;
  70054. /**
  70055. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70056. * will avoid calculating useless pixels in the pixel shader of the water material.
  70057. */
  70058. disableClipPlane: boolean;
  70059. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70060. private _mesh;
  70061. private _refractionRTT;
  70062. private _reflectionRTT;
  70063. private _reflectionTransform;
  70064. private _lastTime;
  70065. private _lastDeltaTime;
  70066. private _renderId;
  70067. private _useLogarithmicDepth;
  70068. private _waitingRenderList;
  70069. private _imageProcessingConfiguration;
  70070. private _imageProcessingObserver;
  70071. /**
  70072. * Gets a boolean indicating that current material needs to register RTT
  70073. */
  70074. readonly hasRenderTargetTextures: boolean;
  70075. /**
  70076. * Constructor
  70077. */
  70078. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70079. useLogarithmicDepth: boolean;
  70080. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70081. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70082. addToRenderList(node: any): void;
  70083. enableRenderTargets(enable: boolean): void;
  70084. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70085. readonly renderTargetsEnabled: boolean;
  70086. needAlphaBlending(): boolean;
  70087. needAlphaTesting(): boolean;
  70088. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70089. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70090. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70091. private _createRenderTargets;
  70092. getAnimatables(): BABYLON.IAnimatable[];
  70093. getActiveTextures(): BABYLON.BaseTexture[];
  70094. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70095. dispose(forceDisposeEffect?: boolean): void;
  70096. clone(name: string): WaterMaterial;
  70097. serialize(): any;
  70098. getClassName(): string;
  70099. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70100. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70101. }
  70102. }
  70103. declare module BABYLON {
  70104. /** @hidden */
  70105. export var asciiartPixelShader: {
  70106. name: string;
  70107. shader: string;
  70108. };
  70109. }
  70110. declare module BABYLON {
  70111. /**
  70112. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70113. *
  70114. * It basically takes care rendering the font front the given font size to a texture.
  70115. * This is used later on in the postprocess.
  70116. */
  70117. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70118. private _font;
  70119. private _text;
  70120. private _charSize;
  70121. /**
  70122. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70123. */
  70124. readonly charSize: number;
  70125. /**
  70126. * Create a new instance of the Ascii Art FontTexture class
  70127. * @param name the name of the texture
  70128. * @param font the font to use, use the W3C CSS notation
  70129. * @param text the caracter set to use in the rendering.
  70130. * @param scene the scene that owns the texture
  70131. */
  70132. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70133. /**
  70134. * Gets the max char width of a font.
  70135. * @param font the font to use, use the W3C CSS notation
  70136. * @return the max char width
  70137. */
  70138. private getFontWidth;
  70139. /**
  70140. * Gets the max char height of a font.
  70141. * @param font the font to use, use the W3C CSS notation
  70142. * @return the max char height
  70143. */
  70144. private getFontHeight;
  70145. /**
  70146. * Clones the current AsciiArtTexture.
  70147. * @return the clone of the texture.
  70148. */
  70149. clone(): AsciiArtFontTexture;
  70150. /**
  70151. * Parses a json object representing the texture and returns an instance of it.
  70152. * @param source the source JSON representation
  70153. * @param scene the scene to create the texture for
  70154. * @return the parsed texture
  70155. */
  70156. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70157. }
  70158. /**
  70159. * Option available in the Ascii Art Post Process.
  70160. */
  70161. export interface IAsciiArtPostProcessOptions {
  70162. /**
  70163. * The font to use following the w3c font definition.
  70164. */
  70165. font?: string;
  70166. /**
  70167. * The character set to use in the postprocess.
  70168. */
  70169. characterSet?: string;
  70170. /**
  70171. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70172. * This number is defined between 0 and 1;
  70173. */
  70174. mixToTile?: number;
  70175. /**
  70176. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70177. * This number is defined between 0 and 1;
  70178. */
  70179. mixToNormal?: number;
  70180. }
  70181. /**
  70182. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70183. *
  70184. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70185. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70186. */
  70187. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70188. /**
  70189. * The font texture used to render the char in the post process.
  70190. */
  70191. private _asciiArtFontTexture;
  70192. /**
  70193. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70194. * This number is defined between 0 and 1;
  70195. */
  70196. mixToTile: number;
  70197. /**
  70198. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70199. * This number is defined between 0 and 1;
  70200. */
  70201. mixToNormal: number;
  70202. /**
  70203. * Instantiates a new Ascii Art Post Process.
  70204. * @param name the name to give to the postprocess
  70205. * @camera the camera to apply the post process to.
  70206. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70207. */
  70208. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70209. }
  70210. }
  70211. declare module BABYLON {
  70212. /** @hidden */
  70213. export var digitalrainPixelShader: {
  70214. name: string;
  70215. shader: string;
  70216. };
  70217. }
  70218. declare module BABYLON {
  70219. /**
  70220. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70221. *
  70222. * It basically takes care rendering the font front the given font size to a texture.
  70223. * This is used later on in the postprocess.
  70224. */
  70225. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70226. private _font;
  70227. private _text;
  70228. private _charSize;
  70229. /**
  70230. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70231. */
  70232. readonly charSize: number;
  70233. /**
  70234. * Create a new instance of the Digital Rain FontTexture class
  70235. * @param name the name of the texture
  70236. * @param font the font to use, use the W3C CSS notation
  70237. * @param text the caracter set to use in the rendering.
  70238. * @param scene the scene that owns the texture
  70239. */
  70240. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70241. /**
  70242. * Gets the max char width of a font.
  70243. * @param font the font to use, use the W3C CSS notation
  70244. * @return the max char width
  70245. */
  70246. private getFontWidth;
  70247. /**
  70248. * Gets the max char height of a font.
  70249. * @param font the font to use, use the W3C CSS notation
  70250. * @return the max char height
  70251. */
  70252. private getFontHeight;
  70253. /**
  70254. * Clones the current DigitalRainFontTexture.
  70255. * @return the clone of the texture.
  70256. */
  70257. clone(): DigitalRainFontTexture;
  70258. /**
  70259. * Parses a json object representing the texture and returns an instance of it.
  70260. * @param source the source JSON representation
  70261. * @param scene the scene to create the texture for
  70262. * @return the parsed texture
  70263. */
  70264. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70265. }
  70266. /**
  70267. * Option available in the Digital Rain Post Process.
  70268. */
  70269. export interface IDigitalRainPostProcessOptions {
  70270. /**
  70271. * The font to use following the w3c font definition.
  70272. */
  70273. font?: string;
  70274. /**
  70275. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70276. * This number is defined between 0 and 1;
  70277. */
  70278. mixToTile?: number;
  70279. /**
  70280. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70281. * This number is defined between 0 and 1;
  70282. */
  70283. mixToNormal?: number;
  70284. }
  70285. /**
  70286. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70287. *
  70288. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70289. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70290. */
  70291. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70292. /**
  70293. * The font texture used to render the char in the post process.
  70294. */
  70295. private _digitalRainFontTexture;
  70296. /**
  70297. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70298. * This number is defined between 0 and 1;
  70299. */
  70300. mixToTile: number;
  70301. /**
  70302. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70303. * This number is defined between 0 and 1;
  70304. */
  70305. mixToNormal: number;
  70306. /**
  70307. * Instantiates a new Digital Rain Post Process.
  70308. * @param name the name to give to the postprocess
  70309. * @camera the camera to apply the post process to.
  70310. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70311. */
  70312. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70313. }
  70314. }
  70315. declare module BABYLON {
  70316. /** @hidden */
  70317. export var oceanPostProcessPixelShader: {
  70318. name: string;
  70319. shader: string;
  70320. };
  70321. }
  70322. declare module BABYLON {
  70323. /**
  70324. * Option available in the Ocean Post Process.
  70325. */
  70326. export interface IOceanPostProcessOptions {
  70327. /**
  70328. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70329. */
  70330. reflectionSize?: number | {
  70331. width: number;
  70332. height: number;
  70333. } | {
  70334. ratio: number;
  70335. };
  70336. /**
  70337. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70338. */
  70339. refractionSize?: number | {
  70340. width: number;
  70341. height: number;
  70342. } | {
  70343. ratio: number;
  70344. };
  70345. }
  70346. /**
  70347. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70348. *
  70349. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70350. * Example usage:
  70351. * var pp = new OceanPostProcess("myOcean", camera);
  70352. * pp.reflectionEnabled = true;
  70353. * pp.refractionEnabled = true;
  70354. */
  70355. export class OceanPostProcess extends BABYLON.PostProcess {
  70356. /**
  70357. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70358. */
  70359. /**
  70360. * Sets weither or not the real-time reflection is enabled on the ocean.
  70361. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70362. */
  70363. reflectionEnabled: boolean;
  70364. /**
  70365. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70366. */
  70367. /**
  70368. * Sets weither or not the real-time refraction is enabled on the ocean.
  70369. * Is set to true, the refraction render target texture will be used as refraction texture.
  70370. */
  70371. refractionEnabled: boolean;
  70372. /**
  70373. * Gets wether or not the post-processes is supported by the running hardware.
  70374. * This requires draw buffer supports.
  70375. */
  70376. readonly isSupported: boolean;
  70377. /**
  70378. * This is the reflection mirror texture used to display reflections on the ocean.
  70379. * By default, render list is empty.
  70380. */
  70381. reflectionTexture: BABYLON.MirrorTexture;
  70382. /**
  70383. * This is the refraction render target texture used to display refraction on the ocean.
  70384. * By default, render list is empty.
  70385. */
  70386. refractionTexture: BABYLON.RenderTargetTexture;
  70387. private _time;
  70388. private _cameraRotation;
  70389. private _cameraViewMatrix;
  70390. private _reflectionEnabled;
  70391. private _refractionEnabled;
  70392. private _geometryRenderer;
  70393. /**
  70394. * Instantiates a new Ocean Post Process.
  70395. * @param name the name to give to the postprocess.
  70396. * @camera the camera to apply the post process to.
  70397. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70398. */
  70399. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70400. /**
  70401. * Returns the appropriate defines according to the current configuration.
  70402. */
  70403. private _getDefines;
  70404. /**
  70405. * Computes the current camera rotation as the shader requires a camera rotation.
  70406. */
  70407. private _computeCameraRotation;
  70408. }
  70409. }
  70410. declare module BABYLON {
  70411. /** @hidden */
  70412. export var brickProceduralTexturePixelShader: {
  70413. name: string;
  70414. shader: string;
  70415. };
  70416. }
  70417. declare module BABYLON {
  70418. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70419. private _numberOfBricksHeight;
  70420. private _numberOfBricksWidth;
  70421. private _jointColor;
  70422. private _brickColor;
  70423. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70424. updateShaderUniforms(): void;
  70425. numberOfBricksHeight: number;
  70426. numberOfBricksWidth: number;
  70427. jointColor: BABYLON.Color3;
  70428. brickColor: BABYLON.Color3;
  70429. /**
  70430. * Serializes this brick procedural texture
  70431. * @returns a serialized brick procedural texture object
  70432. */
  70433. serialize(): any;
  70434. /**
  70435. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70436. * @param parsedTexture defines parsed texture data
  70437. * @param scene defines the current scene
  70438. * @param rootUrl defines the root URL containing brick procedural texture information
  70439. * @returns a parsed Brick Procedural BABYLON.Texture
  70440. */
  70441. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70442. }
  70443. }
  70444. declare module BABYLON {
  70445. /** @hidden */
  70446. export var cloudProceduralTexturePixelShader: {
  70447. name: string;
  70448. shader: string;
  70449. };
  70450. }
  70451. declare module BABYLON {
  70452. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70453. private _skyColor;
  70454. private _cloudColor;
  70455. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70456. updateShaderUniforms(): void;
  70457. skyColor: BABYLON.Color4;
  70458. cloudColor: BABYLON.Color4;
  70459. /**
  70460. * Serializes this cloud procedural texture
  70461. * @returns a serialized cloud procedural texture object
  70462. */
  70463. serialize(): any;
  70464. /**
  70465. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70466. * @param parsedTexture defines parsed texture data
  70467. * @param scene defines the current scene
  70468. * @param rootUrl defines the root URL containing cloud procedural texture information
  70469. * @returns a parsed Cloud Procedural BABYLON.Texture
  70470. */
  70471. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70472. }
  70473. }
  70474. declare module BABYLON {
  70475. /** @hidden */
  70476. export var fireProceduralTexturePixelShader: {
  70477. name: string;
  70478. shader: string;
  70479. };
  70480. }
  70481. declare module BABYLON {
  70482. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70483. private _time;
  70484. private _speed;
  70485. private _autoGenerateTime;
  70486. private _fireColors;
  70487. private _alphaThreshold;
  70488. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70489. updateShaderUniforms(): void;
  70490. render(useCameraPostProcess?: boolean): void;
  70491. static readonly PurpleFireColors: BABYLON.Color3[];
  70492. static readonly GreenFireColors: BABYLON.Color3[];
  70493. static readonly RedFireColors: BABYLON.Color3[];
  70494. static readonly BlueFireColors: BABYLON.Color3[];
  70495. autoGenerateTime: boolean;
  70496. fireColors: BABYLON.Color3[];
  70497. time: number;
  70498. speed: BABYLON.Vector2;
  70499. alphaThreshold: number;
  70500. /**
  70501. * Serializes this fire procedural texture
  70502. * @returns a serialized fire procedural texture object
  70503. */
  70504. serialize(): any;
  70505. /**
  70506. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70507. * @param parsedTexture defines parsed texture data
  70508. * @param scene defines the current scene
  70509. * @param rootUrl defines the root URL containing fire procedural texture information
  70510. * @returns a parsed Fire Procedural BABYLON.Texture
  70511. */
  70512. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70513. }
  70514. }
  70515. declare module BABYLON {
  70516. /** @hidden */
  70517. export var grassProceduralTexturePixelShader: {
  70518. name: string;
  70519. shader: string;
  70520. };
  70521. }
  70522. declare module BABYLON {
  70523. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70524. private _grassColors;
  70525. private _groundColor;
  70526. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70527. updateShaderUniforms(): void;
  70528. grassColors: BABYLON.Color3[];
  70529. groundColor: BABYLON.Color3;
  70530. /**
  70531. * Serializes this grass procedural texture
  70532. * @returns a serialized grass procedural texture object
  70533. */
  70534. serialize(): any;
  70535. /**
  70536. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70537. * @param parsedTexture defines parsed texture data
  70538. * @param scene defines the current scene
  70539. * @param rootUrl defines the root URL containing grass procedural texture information
  70540. * @returns a parsed Grass Procedural BABYLON.Texture
  70541. */
  70542. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70543. }
  70544. }
  70545. declare module BABYLON {
  70546. /** @hidden */
  70547. export var marbleProceduralTexturePixelShader: {
  70548. name: string;
  70549. shader: string;
  70550. };
  70551. }
  70552. declare module BABYLON {
  70553. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70554. private _numberOfTilesHeight;
  70555. private _numberOfTilesWidth;
  70556. private _amplitude;
  70557. private _jointColor;
  70558. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70559. updateShaderUniforms(): void;
  70560. numberOfTilesHeight: number;
  70561. amplitude: number;
  70562. numberOfTilesWidth: number;
  70563. jointColor: BABYLON.Color3;
  70564. /**
  70565. * Serializes this marble procedural texture
  70566. * @returns a serialized marble procedural texture object
  70567. */
  70568. serialize(): any;
  70569. /**
  70570. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70571. * @param parsedTexture defines parsed texture data
  70572. * @param scene defines the current scene
  70573. * @param rootUrl defines the root URL containing marble procedural texture information
  70574. * @returns a parsed Marble Procedural BABYLON.Texture
  70575. */
  70576. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70577. }
  70578. }
  70579. declare module BABYLON {
  70580. /** @hidden */
  70581. export var normalMapProceduralTexturePixelShader: {
  70582. name: string;
  70583. shader: string;
  70584. };
  70585. }
  70586. declare module BABYLON {
  70587. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70588. private _baseTexture;
  70589. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70590. updateShaderUniforms(): void;
  70591. render(useCameraPostProcess?: boolean): void;
  70592. resize(size: any, generateMipMaps: any): void;
  70593. baseTexture: BABYLON.Texture;
  70594. /**
  70595. * Serializes this normal map procedural texture
  70596. * @returns a serialized normal map procedural texture object
  70597. */
  70598. serialize(): any;
  70599. /**
  70600. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70601. * @param parsedTexture defines parsed texture data
  70602. * @param scene defines the current scene
  70603. * @param rootUrl defines the root URL containing normal map procedural texture information
  70604. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70605. */
  70606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70607. }
  70608. }
  70609. declare module BABYLON {
  70610. /** @hidden */
  70611. export var perlinNoiseProceduralTexturePixelShader: {
  70612. name: string;
  70613. shader: string;
  70614. };
  70615. }
  70616. declare module BABYLON {
  70617. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70618. time: number;
  70619. timeScale: number;
  70620. translationSpeed: number;
  70621. private _currentTranslation;
  70622. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70623. updateShaderUniforms(): void;
  70624. render(useCameraPostProcess?: boolean): void;
  70625. resize(size: any, generateMipMaps: any): void;
  70626. /**
  70627. * Serializes this perlin noise procedural texture
  70628. * @returns a serialized perlin noise procedural texture object
  70629. */
  70630. serialize(): any;
  70631. /**
  70632. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70633. * @param parsedTexture defines parsed texture data
  70634. * @param scene defines the current scene
  70635. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70636. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70637. */
  70638. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70639. }
  70640. }
  70641. declare module BABYLON {
  70642. /** @hidden */
  70643. export var roadProceduralTexturePixelShader: {
  70644. name: string;
  70645. shader: string;
  70646. };
  70647. }
  70648. declare module BABYLON {
  70649. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70650. private _roadColor;
  70651. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70652. updateShaderUniforms(): void;
  70653. roadColor: BABYLON.Color3;
  70654. /**
  70655. * Serializes this road procedural texture
  70656. * @returns a serialized road procedural texture object
  70657. */
  70658. serialize(): any;
  70659. /**
  70660. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70661. * @param parsedTexture defines parsed texture data
  70662. * @param scene defines the current scene
  70663. * @param rootUrl defines the root URL containing road procedural texture information
  70664. * @returns a parsed Road Procedural BABYLON.Texture
  70665. */
  70666. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70667. }
  70668. }
  70669. declare module BABYLON {
  70670. /** @hidden */
  70671. export var starfieldProceduralTexturePixelShader: {
  70672. name: string;
  70673. shader: string;
  70674. };
  70675. }
  70676. declare module BABYLON {
  70677. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70678. private _time;
  70679. private _alpha;
  70680. private _beta;
  70681. private _zoom;
  70682. private _formuparam;
  70683. private _stepsize;
  70684. private _tile;
  70685. private _brightness;
  70686. private _darkmatter;
  70687. private _distfading;
  70688. private _saturation;
  70689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70690. updateShaderUniforms(): void;
  70691. time: number;
  70692. alpha: number;
  70693. beta: number;
  70694. formuparam: number;
  70695. stepsize: number;
  70696. zoom: number;
  70697. tile: number;
  70698. brightness: number;
  70699. darkmatter: number;
  70700. distfading: number;
  70701. saturation: number;
  70702. /**
  70703. * Serializes this starfield procedural texture
  70704. * @returns a serialized starfield procedural texture object
  70705. */
  70706. serialize(): any;
  70707. /**
  70708. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70709. * @param parsedTexture defines parsed texture data
  70710. * @param scene defines the current scene
  70711. * @param rootUrl defines the root URL containing startfield procedural texture information
  70712. * @returns a parsed Starfield Procedural BABYLON.Texture
  70713. */
  70714. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70715. }
  70716. }
  70717. declare module BABYLON {
  70718. /** @hidden */
  70719. export var woodProceduralTexturePixelShader: {
  70720. name: string;
  70721. shader: string;
  70722. };
  70723. }
  70724. declare module BABYLON {
  70725. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70726. private _ampScale;
  70727. private _woodColor;
  70728. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70729. updateShaderUniforms(): void;
  70730. ampScale: number;
  70731. woodColor: BABYLON.Color3;
  70732. /**
  70733. * Serializes this wood procedural texture
  70734. * @returns a serialized wood procedural texture object
  70735. */
  70736. serialize(): any;
  70737. /**
  70738. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  70739. * @param parsedTexture defines parsed texture data
  70740. * @param scene defines the current scene
  70741. * @param rootUrl defines the root URL containing wood procedural texture information
  70742. * @returns a parsed Wood Procedural BABYLON.Texture
  70743. */
  70744. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  70745. }
  70746. }